Shaves
Shaves

Reputation: 930

Access 2010 No records returned based on date/time field

I must be brain dead today because I cannot get any records to return in a SELECY query. I'm trying to select records for the last 30 days (since 2/8/2016). I know there are records in the database since 2/8/16. This is my selection criteria: >#2/7/2016 11:59:59 PM#. I'm not sure why I'm not getting any records. I've looked at the table and the field I'm trying to select on is Date/Time (General Date format). Any suggestions would be appreciated as this is making me crazy. Thanks for the help.

Upvotes: 0

Views: 31

Answers (2)

Gustav
Gustav

Reputation: 55816

Use this criteria for your date field:

>=DateAdd("d",-30,Date())

or for a specific date:

>=DateAdd("d",-30,DateSerial(2016,3,1))

or, if 30 days means a month:

>=DateAdd("m",-1,Date())

Upvotes: 0

Josetta Caudill
Josetta Caudill

Reputation: 56

I would just use the date part of it, without the time. So...

=#2/8/2016#

If this is to be variable date for the last 30 days from today, you could also write it as

=Now()-30

Hope this helps.

Josetta

Upvotes: 0

Related Questions