Name
CompareDates -- compare two date strings (V4.5)
Synopsis
result = CompareDates(date1$, date2$[, notime])
Function
This function can be used to compare the time of two date strings and return their relation. Both date strings must be in the default time notation used by Hollywood:

 
dd-mmm-yyyy hh:mm:ss

The mmm constituent is a string with three characters identifying the month. This can be Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, or Dec.

If you set the optional argument notime to True, only dates are compared. In that case, the two strings you pass to CompareDates() must not contain any time specifications.

The return value of CompareDates() indicates how the two dates are related. The following return values are possible:

0:
date1$ and date$ have exactly the same time

1:
date1$ is later in time than date2$

2:
date1$ is earlier in time than date2$

Inputs
date1$
date string in the Hollywood date notation
date2$
date string in the Hollywood date notation
notime
optional: True to compare dates only (defaults to False)
Results
result
result of comparison
Example
NPrint(CompareDates("10-Dec-2009 13:34:12", "09-Dec-2009 15:36:21"))
NPrint(CompareDates("12-Dec-2009 23:59:59", "13-Dec-2009 00:00:00"))
NPrint(CompareDates("24-Dec-2009 20:00:00", "24-Dec-2009 20:00:00"))
The code above will do three date comparisons. The results will be: 1,2,0

Show TOC