Name
DateCompare
Synopsis
DateCompare(date1, date2
[,datepart
])
Compares two date/time objects. Returns -1 if
date1
is less than
date2
, 0 if both date/time objects are
equal, or 1 if date1
is greater than
date2
. The comparison may be limited to a
specific part of the date/time object by specifying a value for the
optional datepart
parameter. Valid
attributes for datepart
are:
s
(second), n
(minute),
h
(hour), d
(day),
m
(month), and yyyy
(year).
Examples:
<CFOUTPUT> Compare 08/15/99 and 08/15/99: #DateCompare('08/15/99', '08/15/99')#<BR> Compare 08/15/99 and 08/15/1999: #DateCompare('08/15/99', '08/15/1999')#<BR> Compare 15 Aug 1998 and 8/15/98: #DateCompare('15 Aug 1998', '8/15/98')#<BR> Compare August 15, 1998 and July 4, 1997: #DateCompare('August 15, 1998', 'July 4, 1997')#<BR> Compare 19:00:00 and 7pm: #DateCompare('19:00:00', '7pm')#<BR> Compare 6:00 and 7:00: #DateCompare('6:00', '7:00')#<BR> Compare 8/15/1998 and Jan 3, 1999 by year: #DateCompare('8/15/1998', 'Jan 3, 1999', 'yyyy')#<BR> Compare 6:59 and 7:38 by minute: #DateCompare('6:59', '7:38', 'n')# </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.