Vladi243 Posted November 2, 2008 Share Posted November 2, 2008 Hello, Is there a way in autoit to calculate hours difference? For example I want to calculate the hours difference between 12:48 and 17:27. I need the shortest script to calculate this kind of things. Thanks. Link to comment Share on other sites More sharing options...
i542 Posted November 2, 2008 Share Posted November 2, 2008 _DateDiff UDF. I can do signature me. Link to comment Share on other sites More sharing options...
Vladi243 Posted November 2, 2008 Author Share Posted November 2, 2008 _DateDiff UDF.Can you give me an example?I haven't found it in the help file. I only found the function _DateDiff. Link to comment Share on other sites More sharing options...
i542 Posted November 2, 2008 Share Posted November 2, 2008 Can you give me an example?I haven't found it in the help file. I only found the function _DateDiff.Thats the one I can do signature me. Link to comment Share on other sites More sharing options...
Malkey Posted November 3, 2008 Share Posted November 3, 2008 Can you give me an example? I haven't found it in the help file. I only found the function _DateDiff.You have probably worked this out by now. _DateDiff() is a little tricky at first use, I found. Here is an example for the time difference in hours and minutes. #include <Date.au3> $sFinishTime = "17:27" ; Proper format in the form of "2008/02/01 02:15:00" $sStartTime = "12:48" ; Returns total number of hours only, an integer (no decimal of an hour). $intTotalHrDiff = _DateDiff('h', "1970/01/01 " & $sStartTime & ":00", "1970/01/01 " & $sFinishTime & ":00") ; Returns total number of minutes only, an integer. $intTotalMinDiff = _DateDiff('n', "1970/01/01 " & $sStartTime & ":00", "1970/01/01 " & $sFinishTime & ":00") MsgBox(4096, "", "First Time difference " & @CRLF & @CRLF & $intTotalHrDiff & " hr " & _ $intTotalMinDiff - ($intTotalHrDiff * 60) & " min") ;======================================================= ; Above shortened $intTotalHrDiff = _DateDiff('h', "1970/01/01 " & $sStartTime & ":00", "1970/01/01 " & $sFinishTime & ":00") $sHrMinDiff = $intTotalHrDiff & " hr " & _DateDiff('n', "1970/01/01 " & $sStartTime & ":00", "1970/01/01 " & _ $sFinishTime & ":00") - ($intTotalHrDiff * 60) & " min" MsgBox(4096, "", "Second Time difference " & @CRLF & @CRLF & $sHrMinDiff) An example for days,hours, and minute difference see http://www.autoitscript.com/forum/index.ph...st&p=592906 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now