The datecmp() function compares two dates and returns the results of the comparison.
The two input parameters, date1 and date2, contain the date strings to compare. These fields should have the format YYYY/MM/DD, where:
|YYYY||A year numeric character string such as 2001. If the specified year is only two digits, then that value is automatically concatenated with 19 to form a year between 1900 and 1999, inclusive. For example, if the value 01 is supplied for year, the actual year value is processed as 1901.|
|MM||Month between 1 and 12 inclusive|
|DD||Day between 1 and 31 inclusive.|
Use the forward slash character (/) as a field separator. Zeros or spaces can be used as leading pad characters for the year, month, or day.
result = datecmp (date1, date2);
|date1||Required. Character string containing a date formatted as YYYY/MM/DD|
|date2||Required. Character string containing a date formatted as YYYY/MM/DD|
|Negative Integer||A negative integer is returned if date1 is less than date2 (date1 < date2).|
|0||Zero is returned if date1 is equal to date2 (date1 == date2).|
|Positive Integer||A positive integer is returned if date1 is greater than date2 (date1 < date2).|
In the example,
date1 = "2001/01/21"; result = datecmp (date1, "2002/01/21");
datecmp compares the value in date1 against the date January 21, 2002. The result is returned in result. Because date1 contains the date 2001/01/21, the result of datecmp is a negative integer because date1 is less than date2.