Performs a full date/time comparison of two dates.
DateCompare(date1, date2 [, datePart])
Parameter |
Description |
|---|---|
date1 |
Date/time object, in the range 100 AD-9999 AD. |
date2 |
Date/time object, in the range 100 AD-9999 AD. |
datePart |
Optional. String. Precision of the comparison.
|
When passing a date/time object as a string, enclose it in quotation marks. Otherwise, it is interpreted as a numeric representation of a date/time object.
<cfscript>
Date1 = "{ts '2018-11-15 12:13:50'}";
Date2 = "{ts '2018-10-15 11:13:50'}";
Date3 = "{ts '2018-11-15 12:13:50'}";
Date4 = "{ts '2019-11-15 12:13:50'}";
Compare= DateCompare(Date1,Date2)
Compare1= DateCompare(Date1,Date3)
Compare2= DateCompare(Date1,Date4)
writeOutput("date comparison is : " & Compare & "<br/>")
writeOutput("date comparison is : " & Compare1 & "<br/>")
writeOutput("date comparison is : " & Compare2 & "<br/>")
</cfscript>
Output
date comparison is : 1
date comparison is : 0
date comparison is : -1
Sign in to your account