• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

DateDiff

Synopsis

                  DateDiff(datepart, date1, date2)

Returns the interval in datepart units by which date2 is greater than date1. Dates must be in the range AD 100-9999. 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. For information on how ColdFusion MX handles two-digit years, see CreateDate( ). 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>....

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint