Returns the difference between 2 dates, expressed in the type requested
#include <Date.au3>
_DateDiff ( $sType, $sStartDate, $sEndDate )
$sType | One of the following: D = Difference in days between the given dates M = Difference in months between the given dates Y = Difference in years between the given dates w = Difference in Weeks between the given dates h = Difference in hours between the given dates n = Difference in minutes between the given dates s = Difference in seconds between the given dates |
$sStartDate | Input Start date in the format "YYYY/MM/DD[ HH:MM:SS]" |
$sEndDate | Input End date in the format "YYYY/MM/DD[ HH:MM:SS]" |
Success: | Difference between the 2 dates. |
Failure: | 0 and sets the @error flag to non-zero. |
@error: | 1 - Invalid $sType 2 - Invalid $sStartDate 3 - Invalid $sEndDate |
Valid dates must be between "1000/01/01 00:00:00". and "3000/12/31 23:59:59"
See _DateTimeSplit() for other possible variations of the start and end date formats.
_DateAdd, _DateTimeSplit, _DateToDayOfWeek, _DateToDayOfWeekISO, _DateToDayValue, _DayValueToDate, _NowCalc
#include <Date.au3>
#include <MsgBoxConstants.au3>
; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
Local $iDateCalc = _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "Number of seconds since EPOCH: " & $iDateCalc)
; Calculated the number of Hours this year
$iDateCalc = _DateDiff('h', @YEAR & "/01/01 00:00:00", _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "Number of Hours this year: " & $iDateCalc)