
Y2K issue with DateAdd in CF 4.1 and CF 4.5
I used DateAdd to create a new date based off a number of seconds.<CFSET PendTime=DateAdd("s",Now(),secs)>Using a debug message, I got this information back:Adding 496 seconds to the current time of 01/11/2000 14:21:19 and returned 05/10/1901 10:08:56
However, when I used CreateTimeSpan instead, it worked correctly.<CFSET m=Int(secs/60)>
<CFSET s=secs-m*60>
<CFSET PendTime=Now() + CreateTimeSpan(0,0,m,s)>
Which returned:Adding 448 seconds to the current time of 01/11/2000 14:32:44 and returned 01/11/2000 14:40:12
Note that the link to DateAdd is not in the index of Date and Time functions but it is listed under the "See also" list of CreateTimeSpan in the Cold Fusion 4.5 docs.
Basically, don't use DateAdd.
Return to the Cold Fusion Tips-N-Tricks topic list