G
Guest
Hi,
Regarding date comparisons, all of the following will return the same result:
If Date1 > Date2 Then ...
If Datediff("d", Date1, Date2) < 0 Then ...
If Date2 - Date1 < 0 Then ...
But which is the more correct? I am in Australia so my system date is
dd-mm-yyyy, and it is very easy to get mixed up when using sql etc... where
US format is needed (mm-dd-yyyy). I'm trying to tidy my date coding habits up
a little, and assume using Datediff() should be internationally compliant.
The same for adding dates:
Date1 + 7 adds 7 days to the date, but
DateAdd("d", 7, Date1) should be the correct format to use?
Any rules of thumb appreciated.
Thanks.
swas
Regarding date comparisons, all of the following will return the same result:
If Date1 > Date2 Then ...
If Datediff("d", Date1, Date2) < 0 Then ...
If Date2 - Date1 < 0 Then ...
But which is the more correct? I am in Australia so my system date is
dd-mm-yyyy, and it is very easy to get mixed up when using sql etc... where
US format is needed (mm-dd-yyyy). I'm trying to tidy my date coding habits up
a little, and assume using Datediff() should be internationally compliant.
The same for adding dates:
Date1 + 7 adds 7 days to the date, but
DateAdd("d", 7, Date1) should be the correct format to use?
Any rules of thumb appreciated.
Thanks.
swas