Performs a full date/time comparison of two dates.
-1
if date1 is less than date2
0
if date1 is equal to date2
1
if date1 is greater than date2
[DatePart] yyyy
: Year; m
: Month; d
: Day; h
: Hour; n
: Minute; s
: Second
dateCompare(date1, date2 [, datePart])
→ returns numeric
date1.compare(date2 [, datePart])
s
yyyy
m
y
d
h
n
s
dateCompare('12/30/2015', '12/02/2015', 'yyyy')
Expected Result: 0
Returns 1 because date1 is greater than date 2
dateCompare('12/30/2015', '12/02/2015', 'd')
Expected Result: 1
d1 = createDate("2024","01","01");
d2 = createDate("2024","02","14");
d1.compare(d2)
Expected Result: -1
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.