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

Name

DateAdd

Synopsis

                   DateAdd(datepart, number, date)

Adds number to the datepart of the specified date. Dates must be in the range AD 100-9999. To subtract, make number negative. Valid entries for datepart are l (millisecond), s (second), n (minute), h (hour), ww (week), w (weekday), d (day), y (day of year), m (month), q (quarter), and yyyy (year). For information on how ColdFusion MX handles two-digit years, see CreateDate( ). Examples:

<cfset MyDateTime = Now( )>
   
<cfoutput>The original time and date is 
#TimeFormat(MyDateTime,'hh:mm:ss tt')#, #DateFormat(MyDateTime,'mmmm dd, yyyy')#
   
<p><b>Add 30 Seconds:</b> 
#TimeFormat(DateAdd('s', 30, MyDateTime),'hh:mm:ss tt')#
<br><b>Subtract 10 minutes:</b> 
#TimeFormat(DateAdd('n', -10, MyDateTime),'hh:mm:ss tt')#
<br><b>Add 2 hours:</b> 
#TimeFormat(DateAdd('h', 2, MyDateTime),'hh:mm:ss tt')#
<br><b>Add 9 weeks:</b> 
#DateFormat(DateAdd('ww', 9, MyDateTime),'mmmm dd, yyyy')#
<br><b>Add 3 weekdays:</b> 
#DateFormat(DateAdd('w', 3, MyDateTime),'mmmm dd, yyyy')#
<br><b>Subtract 67 days:</b> 
#DateFormat(DateAdd('d', -67, MyDateTime),'mmmm dd, yyyy')#
<br><b>Add 45 days of the year:</b> 
#DateFormat(DateAdd('y', 45, MyDateTim....

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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