dateCompare

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 - quicky]
yyyy: Year; q: Quarter; m: Month; y: Day of year; d: Day
w: Weekday; ww: Week; h: Hour; n: Minute; s: Second;
l: Millisecond

dateCompare(date1, date2 [, datePart]) → returns Numeric

Argument Reference for the dateCompare function

Name Required Default Description
date1 Yes
  • now()
date2 Yes
  • now()
datePart No
  • yyyy
  • q
  • m
  • y
  • d
  • w
  • ww
  • h
  • n
  • s
  • l

Examples sample code invoking the dateCompare function


Tag Syntax

<cfset comparison = dateCompare('11/30/2015', '12/02/2015', 'yyyy')> 
 <cfdump var="#comparison#">  

Fork me on GitHub