{{sidenavigation.sidenavigationExpandLabel}}
{{getMsg('Help_YouAreHere')}}: {{page.title}} {{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}} {{helpModel.downloadHelpPdfDataStatus}}

DateDiff

Returns the difference between startDateTime and endDateTime, regarding ONLY the intervalType specified, that is, truncating all information more exact than the intervalType specified. For examples, see below.

intervalType substracts
"yyyy" years
"m" months
"q" quarters
"w" weeks (that is, how many 7-day intervals)
"ww" weeks which contain the firstDayOfWeek
"d" days
"h" hours
"n" minutes
"s" seconds
"ms" milliseconds

Say you have two datetimes: One is 3/31/05 11:59:59 p.m. and the other is 4/1/05 12:00:01 a.m. (these two are actually only 2 seconds apart from each other!) Here are the results you would get from DateDiff depending on the various units:

's' - 2 (2 seconds)
'n' - 1 (1 minute - 11:59 p.m. to 12:00 a.m.)
'h' - 1 (1 hour - 11 p.m. to 12 a.m.)
'd' - 1 (1 day - 3/31 to 4/1)
'm' - 1 (1 month - March to April)
'q' - 1 (1 quarter - Q1 to Q2)
'yyyy' - 0 (0 years - 2005 to 2005)

As you can see, information more detailed than the interval type is simply truncated: the minute ('n') difference does not take seconds into account, the month ('m') difference does not take days or hours or minutes or seconds into account, etc.

There are two exceptions to this rule: using the "w" parameter calculates the number of weeks between two dates. This is equivalent to the difference in days, divided by 7, rounded down.

DateDiff ("w", #3/31/2005#, #4/6/2005#) returns 0.
DateDiff ("w", #3/31/2005#, #4/7/2005#) returns 1.

Using the "ww" parameter calculates the number of firstDayOfWeek's between the two dates. This is where the firstDayOfWeek parameter comes in. If it is not specified, the parameter is viewed as Sunday by default, and therefore the function would count the number of Sundays between the two dates. Specifying Thursday as firstDayOfWeek would count the number of Thursdays between the two dates.

DateDiff ("ww", #10/30/2005#, #11/1/2005#) returns 1.
DateDiff ("ww", #10/30/2005#, #11/1/2005#, Thursday) returns 0.
DateDiff ("ww", #10/30/2005#, #11/20/2005#, Friday) returns 3.

Usage:

DateDiff( intervalType,startDateTime, endDateTime )
DateDiff( intervalType,startDateTime, endDateTime, firstDayOfWeek )

Returns:

Number value

Examples:

DateDiff("d", Date(2010, 12, 02), Date(2010, 12, 12)) // returns 10
i-net Clear Reports
This application uses cookies to allow login. By continuing to use this application, you agree to the use of cookies.


Help - DateDiff