Today and yesterday query

Toolpusher

Registered User.
Local time
Today, 15:31
Joined
May 29, 2007
Messages
53
Hi

Want to create two query's for using for reports.
1. Need to see all records entered yesterday, using Date()-2 on the date entered field which seems to work sometimes but not always
2. Need to see all records entered today using Date() does not work for some reason? against the date entered field

Thanks
 
Hi,

The Date() function will return the current system date, so assuming the settings on the computer are correct this will return today's date.

To view the records for yesterday you should use the dateadd function, e.g.

DateToday: Date()
DateYesterday: DateAdd("d", -1, Date())

It is worth checking that the date is set correctly for the computer you are working on.
 
If the date in your table contains time because you populated it with Now(), you need to extract only the date portion in your criteria.

Where DateValue(MyDate) = Date() -1
Of course, this doesn't work on Monday unless you run 7 days per week.
 

Users who are viewing this thread

Back
Top Bottom