Post by colmkavPost by Deanna EarleyPost by colmkavHow can I take a date provided as a time eg now() and convert it to a
date without the hours, minutes etc?
My issue is that I want to compare this date with that of other dates
but at the moment they arent being evaluated as equal because of the
hours and minutes difference.
I use either DateValue() or Int().
I have had unexpected issues with DateValue not working properly with
Date values (as it expects a String, and it got day/month backwards) so
most of my code now uses Int().
seem to get overflow error now when I use INT. Not quite sure why.
Previously when I use contextdate = cdate(now()-1) to set my
contextdate and then use in my SQL query ">= [contextdate]" I get the
results requested but I want to be able to just select the contextdate
and not all those after it.
As others already answered CLng() or Int() would do.
If your code *really* looks like
contextdate = cdate(now()-1)
then why do you use Now() at all?
Have a look at the other related functions Date() and Time() and you'll
see Date() is what you really should use.
To me it looks like you have probably *two* problems:
1) get a contextdate value without the time part
- solved with either Int(), CLng() or Date() - and
2) compare your contextdate value with the stored values from your
db field which may or may not contain DateTime values with a time
part.
If there is a time component in vour db values, one possible solution
would be to use in your SQL query something like
">= [contextdate] AND < [contextdate]+1".
This said, you stated with ">= [contextdate]" in your SQL query you get
the requested results plus all those after it.
That's isn't correct. If contextdate contains a time part, you'll miss
all records with this date with lower time values or no time value at
all.
HTH,
Helmut.