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] yyyy: Year; m: Month; d: Day; h: Hour; n: Minute; s: Second

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

dateCompare Argument Reference

date1 Date
Required

A date to compare

date2 Date
Required

Another date to compare

datePart String
Default: s

Values:
  • yyyy
  • m
  • y
  • d
  • h
  • n
  • s

Examples sample code invoking the dateCompare function


Compare Two Dates by Year

dateCompare('12/30/2015', '12/02/2015', 'yyyy')

Expected Result: 0


Compare Two Dates by Day

Returns 1 because date1 is greater than date 2

dateCompare('12/30/2015', '12/02/2015', 'd')

Expected Result: 1


Fork me on GitHub