Search the Community
Showing results for tags '_datediff'.
-
Guys, I'm experiencing something hard to understand in this code: Why it gives me 0 when I use the variable? It looks JUST like the string that I used for calc. I had to add two different date treatments to run in servers with different languages. #include <Date.au3> #include <Constants.au3> #include <Array.au3> ;All variables Global $line, $sRealResult, $aArray, $sDateHour, $aValues, $sValue1, $sValue2, $aArrayY, $aArrayM, $aArrayD, $sDataFinalBR, $sDataFinalEN funcCalcDateLocal() Func funcCalcDateLocal() Local $LocalTime = 'NET TIME \\localhost | findstr /C:"hora" | findstr /v "^$"' ;Command to execute $bResult = Run(@ComSpec & " /c " & $LocalTime, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;Execute the command While 1 $line = StdoutRead($bResult) If $line <> "" Then ;Eliminate the first blank result $sRealResult = $line If @error Then ExitLoop ExitLoop EndIf WEnd StdioClose($bResult) EndFunc ;==>funcCalcDateLocal $aArray = StringSplit($sRealResult, ' ‚ ', 1) ;Eliminate the comma and split it $sDateHour = $aArray[2]; this is the date " " hour $aValues = StringSplit($sDateHour, ' ', 1) ;Split them $sValue1 = $aValues[1] ; Then Date $sValue2 = $aValues[2] ; and Hour $aArrayDate = StringSplit($sValue1, '/', 1) ;Split them in order to later place them in the right sequence for the servers with different languages $aArrayY = $aArrayDate[3] ; year $aArrayM = $aArrayDate[2] ; month $aArrayD = $aArrayDate[1] ; day $sDataFinalBR = $aArrayY & "/" & $aArrayM & "/" & $aArrayD & " " & $sValue2 ; Server PT-BR final date $sDataFinalEN = $aArrayY & "/" & $aArrayD & "/" & $aArrayM & " " & $sValue2 ; Server EN-US final date MsgBox(64, "Data BR", $sDataFinalBR) MsgBox(64, "Data EN", $sDataFinalEN) Local $iDateCalc1 = _DateDiff('s', $sDataFinalBR, "2017/04/19 16:02:52") ; test 1 Local $iDateCalc2 = _DateDiff('s', "2017/04/19 16:02:52", $sDataFinalBR) ; test 2 Local $iDateCalc3 = _DateDiff('s', "2017/04/19 16:02:52", "2017/04/19 16:02:53") ; test 3 MsgBox(64, "Date Calc - Test 1", $iDateCalc1) MsgBox(64, "Date Calc - Test 2", $iDateCalc2) MsgBox(64, "Date Calc - Test 3", $iDateCalc3)
-
I am assigning the current time stamp to a variable $strtTime and holding the execution for 5 seconds with Sleep and calculating the current time stamp. Ideally, the _DateDiff should give 5 seconds as output as i gave the parameter as s.But it is giving zero 0. Any suggestions....! Global $startTime = _Date_Time_GetLocalTime() $startTime = _Date_Time_SystemTimeToDateTimeStr($startTime) Sleep(5000) $tCur = _Date_Time_GetLocalTime() $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur) $iDateCalc = _DateDiff('s', $startTime, $tCur) MsgBox(0,"$iDateCalc",$iDateCalc) FileWrite ($QTPfile,CHr(34) & $tCur & CHr(34) & Chr(44) & """" & $iDateCalc & """,")