Another example:
<cfoutput>
#datediff("n", "{ts '2005-10-26 12:54:00' }", "{ts '2005-10-28 12:54:00' }")#
</cfoutput>
This would return the difference between the two datetime stamps in "minutes". If we were to put the second timestamp in the first position, and the first timestamp in the second position, then we would get a negative value in "minutes".
You can't get a combination, unless you run the datediff() function twice. But, what you can do is get the number of seconds, and then convert the number of seconds into years, months, days, hours, and minutes to get the exact difference.
Main Topics
Browse All Topics





by: ShytKickerPosted on 2005-10-28 at 09:59:09ID: 15180756
Well supposed we have a complete datetime value such as {ts '2005-10-28 12:54:00' } which can be generated by doing #now()#, we can then get the date difference like this:
.com/coldf usion/7/ht mldocs/wwh elp/ wwhimp l/common/h tml/wwhelp .htm? conte xt=ColdFus ion_Docume ntation&fi le=0000044 0.htm
<cfoutput>
#datediff("d", "{ts '2005-10-26 12:54:00' }", "{ts '2005-10-28 12:54:00' }")#
</cfoutput>
Basically right now we are comparing the date difference in "days" notice the "d", with the first date/time to the second date/time. It should return the value "2". Basically you need 2 datetime stamps and a specifier, which asks in what to give your difference in, "d" = days.
Other specifiers are:
d = day
h = hour
m = month
n = minute
q = quarter
s = second
w = weekday (day of week)
ww = week
y = day of year
yyyy = year
http://livedocs.macromedia