User Guide

DateDiff 553
DateDiff
Description
Determines the integer number of units by which date1 is less than date2.
Returns
A number of units, of type datepart.
Category
Date and time functions
Function syntax
DateDiff("datepart", "date1", "date2")
See also
DateAdd
, DatePart, CreateTimeSpan
History
ColdFusion MX:
Changed how negative date differences are calculated: this function calculates negative date
differences correctly; its output may be different from that in earlier releases.
Changed the w and ww masks; they determine the number of full weeks between the two dates.
Parameters
Usage
The DateDiff function determines the number of complete datepart units between the two
dates; for example, if the datepart parameter is "m" and the dates differ by 55 days, the function
returns 1.
Parameter Description
datepart String specifying the units in which to count; for example yyyy requests a date
difference in whole years.
yyyy: Years
q: Quarters
m: Months
y: Days of year (same as d)
d: Days
w: Weekdays (same as ww)
ww: Weeks
h: Hours
n: Minutes
s: Seconds
date1 Date/time object, in the range 100 AD–9999 AD.
date2 Date/time object, in the range 100 AD–9999 AD.