Name
DateDiff
Synopsis
DateDiff(datepart, date1, date2
)
Returns the interval in datepart
units by
which date2
is greater than
date1
. Valid entries for
datepart
are: s
(second), n
(minute), h
(hour),
ww
(week), w
(weekday),
d
(day), y
(day of year),
m
(month), q
(quarter), and
yyyy
(year). If date1
is greater than date2
, a negative number
is returned. Examples:
<CFSET FirstDate = DateFormat(Now( ),'mm/dd/yyyy')> <CFSET SecondDate = "01/01/2000"> <CFOUTPUT> FirstDate: #FirstDate#<BR> SecondDate: #SecondDate# <P> There are #DateDiff("s", FirstDate, SecondDate)# seconds between #FirstDate# and #SecondDate#.<BR> There are #DateDiff("n", FirstDate, SecondDate)# minutes between #FirstDate# and #SecondDate#.<BR> There are #DateDiff("h", FirstDate, SecondDate)# hours between #FirstDate# and #SecondDate#.<BR> There are #DateDiff("d", FirstDate, SecondDate)# days between #FirstDate# and #SecondDate#.<BR> There are #DateDiff("ww", FirstDate, SecondDate)# weeks between #FirstDate# and #SecondDate#.<BR> There are #DateDiff("m", FirstDate, SecondDate)# months between #FirstDate# and #SecondDate#.<BR> There are #DateDiff("yyyy", FirstDate, SecondDate)# years between #FirstDate# and #SecondDate#.<BR> </CFOUTPUT>
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.