Results 1 to 2 of 2
Thread: Date Comparisons (2002 SP-2)
2003-06-30, 19:48 #1
- Join Date
- May 2001
- MIA (takittodahous), Florida, USA
- Thanked 0 Times in 0 Posts
Date Comparisons (2002 SP-2)
In your vast collective experience, what is the best way to compare dates in SQL statements? I'm trying to run some comparisons and they don't yield correct answers, though the logic seems fine to me...
Is it always preferrable to compare date serials as opposed to formatted dates? Currently I have all the dates in the same format, but not serialed. This seems to work fine when I'm genrating dates or changing them (add or subtract time periods). But when I go to choose a date based on comparison criteria (which date is older between two given dates) the logic isn't applying. dunno why.
How do you usually approach date comparisons?
Thanks for your assistance!
2003-06-30, 20:01 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: Date Comparisons (2002 SP-2)
If you have date fields and/or date functions, you can compare them directly. If you want to use constant dates, put # signs around them, for example #6/30/2003# for 6/30/2003 will be evaluated as "6 divided by 30 divided by 2003". (Note for those outside the USA: you MUST use US date format in SQL).