iif statement in a query

tdenmark

New member
Local time
Today, 01:29
Joined
Aug 24, 2005
Messages
1
I have this query that I want to return only records where the date(mm/dd/yyyy) is less than 30 days old. Anybody got a suggestion?
 
WHERE DateField > (Date() - 30)
 
in Criteria section where the date field is put
Now()-[Date]<30

[Date] (Date is name of column)
 
nshah1013,
The Now() function includes time of day and will often cause problems when used with date comparisons. It is better to just use the date() function in all cases unless you specifically want the time. In this particular case, Now() would be OK but it would NOT be OK if the condition were <=

Date() - DateField < 30

If it is possible for DateField to be a future date, you need to decide if you need to do anything different if the date is in the future.
 
nshah1013,

In addition, if your field is named [date], rename it. MyDate, YourDate, whatever...but not [Date]. 'Date' is a reserved word, the name of a function, and it will ultimately come back to bite you.

Bob
 
Thank you guys for your input. i will keep in mind.
 

Users who are viewing this thread

Back
Top Bottom