Months are different from days

  • Thread starter Thread starter Kevbro7189
  • Start date Start date
K

Kevbro7189

I have a query that looks at a table with a list of dates, and data. I want
to use the query to pull out everything with in the past 3 months (not days
like I have now >(Now()-90). I’m trying to understand expressions in Access
so an explanation would be appreciated.
 
I have a query that looks at a table with a list of dates, and data. I want
to use the query to pull out everything with in the past 3 months (not days
like I have now >(Now()-90). I¢m trying to understand expressions in Access
so an explanation would be appreciated.

The Now() function includes the time of day and will therefore return
different record depending upon the time of day the query is run.
Use Date().

Within the last 3 months:

Between DateAdd("m",-3,Date()) and Date()

The above will work fine.... unless your data includes the time of day
as well as the date.
In that case you must add 1 day to the end date of the criteria:

Between DateAdd("m",-3,Date()) and DateAdd("d",1,Date())
 
If the field to be compared does contain time, a more accurate test would be:
DateValue([SomeDateField]) Between DateAdd("m",-3,Date()) and Date()
 
Thank you for your help. It worked

fredg said:
The Now() function includes the time of day and will therefore return
different record depending upon the time of day the query is run.
Use Date().

Within the last 3 months:

Between DateAdd("m",-3,Date()) and Date()

The above will work fine.... unless your data includes the time of day
as well as the date.
In that case you must add 1 day to the end date of the criteria:

Between DateAdd("m",-3,Date()) and DateAdd("d",1,Date())
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top