DateDiff

Definition:

DateDiff(interval, fromdate, todate[, firstdayofweek, firstweekofyear])

 

Description:

Calculate the number of a specified type of time interval between two date strings.

 

Platforms:

All

 

Parameters:

interval - required

The type of time unit you want to calculate. Possible values are:

"d" - Day

"w" - Weekday (same as "d")

"y" - Day of year (same as "d")

"m" - Month

"yyyy" - Year

"h" - Hour

"n" - Minute

"s" - Second

"ww" - Week of year

"q" - Quarter (3 months)

 

fromdate - required

String containing the start date, date and time or time.

Supported formats for this parameter are the same as those supported by VBScript DateTime objects.

 

todate - required

String containing the end date, date and time or time.

Supported formats for this parameter are the same as those supported by VBScript DateTime objects.

 

firstdayofweek - optional

This parameter is ignored and can be omitted.

 

firstweekofyear - optional

This parameter is ignored and can be omitted.

 

Returns:

int

Number of specified type of time interval between the two dates.

 

Notes:

  • If you specify a month interval, this Method will count the number of different calendar months between the two dates. For example, querying the number of months between 30/01/31/12/2015 17:28:31 and 01/03/2015 would return 2 and between 30/11/2015 and 5/12/2015 would return 1.

  • The end date can be earlier than the start date, which will result in a negative number being returned.

  • If you want to use the current date and time, you can use the Now Method to obtain this in a suitable format for use within this Method.