Jump to content

Hours difference


 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...