RE: FN-FORUM: date compare
date posted 19th August 2003 13:35
Pam:
> I have two dates in the format yyyy-mm-dd. Is there an easy way to test if
> one is earlier than the other or do I have to split then and compare the
> year, month and day seperately.
The reason ISO dates are so nice to work with is that they are *so* easy to
compare. If your language does 'sensible' string comparisons, then just
compare them as strings. Alternatively, just chop out the hyphens, and
compare them as numbers.
Pause to think about it for a second, and you'll see that if the date 'gets
later', so the number/string 'gets larger'.
- Nick Grimshaw
{ if you're not part of the solution, you're part of the precipitate. }