If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Months are different from days
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. |
#2
|
|||
|
|||
Months are different from days
On Mon, 7 Jul 2008 18:57:00 -0700, Kevbro7189 wrote:
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()) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#3
|
|||
|
|||
Months are different from days
If the field to be compared does contain time, a more accurate test would be:
DateValue([SomeDateField]) Between DateAdd("m",-3,Date()) and Date() -- Dave Hargis, Microsoft Access MVP "fredg" wrote: On Mon, 7 Jul 2008 18:57:00 -0700, Kevbro7189 wrote: 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()) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#4
|
|||
|
|||
Months are different from days
Thank you for your help. It worked
"fredg" wrote: On Mon, 7 Jul 2008 18:57:00 -0700, Kevbro7189 wrote: 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()) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
Thread Tools | |
Display Modes | |
|
|