Tags · Functions · Objects
Lucee Function Reference
Choose a function:

Function DATECOMPARE

Compares to date, to the given optional resolution. Returns -1 if date1 is before date2. Returns 1 if date1 is after date2. Returns 0 if equal

Example

datecompare(datetime date1,datetime date2,[string datepart]):number

Arguments

The arguments for this function are set. You can not use other arguments except the following ones.
Name Type Required Default Value Description
date1 datetime  Yes   datetime object  
date2 datetime  Yes   datetime object  
datepart string  No s Precision of the comparison:
  • s (default): Precise to the second
  • n: Precise to the minute
  • h: Precise to the hour
  • d: Precise to the day
  • m: Precise to the month
  • yyyy: Precise to the year