Command Reference : String and Date Function Reference
Syntax: @datediff(d1, d2, u[, f])
Argument 1: date number, d1
Argument 2: date number, d2
Argument 3: time unit, u
Argument 4: double, control flag, f
Return: date number
Returns the difference between two date numbers d1 and d2, measured by time units specified by the time unit string u. The optional parameter f controls handling of business days as described in @dateadd.
The valid time unit string values are: “A” or “Y” (annual), “S” (semi-annual), “Q” (quarters), “MM” (months), “WW” (weeks), “DD” (days), “B” (business days), “HH” (hours), “MI” (minutes), “SS” (seconds).
Suppose that date1 is 730088.0 (December 1, 1999) and date2 is 729754.0 (January 1, 1999), then,
@datediff(730088.0, 729754.0, "dd")
returns 334 for the number of days between the two dates. Note that this is result is simply the difference between the two numbers.
The following expressions calculate differences in months and weeks:
@datediff(730088.0, 729754.0, "mm")
@datediff(730088.0, 729754.0, "ww")
return 11 and 47 for the number of months and weeks between the dates.
Suppose that d1 is 730094.0 (midnight, December 7, 1999), which is a Tuesday, and d2 is 730091.0 (midnight, December 4, 1999), which is the preceding Saturday:
@datediff(d1, d2, "b")
returns 1 for the number of business days between the two dates.
@datediff(d1, d2, "b", 1)
returns 2 for the number of business days between the two dates.