query for Dates between today and 30 days back

  • Thread starter Mitchell_Collen via AccessMonster.com
  • Start date
M

Mitchell_Collen via AccessMonster.com

Hi, I am trying to create a list from a the query that will be ran
frequently, it is supposed to show employees on the list that are have dates
between now and 30 days ago. I think that I am close with the where clause
but no quite. Please will you help me? Thanks, Misty

Ex. for today, 12/4/07, all dates between 12/4/07 and 11/5/07.

Select Date, Employee
From EmpRec
Where Date >=DateSerial(Year(Date()),Day(Date()),1) And <DateSerial(Year(Date
()),Day(Date())+1,30)
 
K

Klatuu

WHERE [Date] BETWEEN DateAdd("d", -30, Date) AND Date

You should change the name of the field Date to something else. Date is an
Access reserved word and can very likely cause problems. Notice I wrapped it
in brackets, but even doing that is not always an assurance it will work
correctly.
 
J

Jerry Whittle

You're trying too hard. :)

Between Date() - 30 and Now()

I used Now() as it will include records up to the minute.

Oh! You're field named "Date" in the EmpRec table could be a problem. Date()
is a reserved word in Access. Therefore your Date field could be getting
confused with the Date function.
 
M

Mitchell_Collen via AccessMonster.com

Thanks for helping me. I will try it.
Misty
WHERE [Date] BETWEEN DateAdd("d", -30, Date) AND Date

You should change the name of the field Date to something else. Date is an
Access reserved word and can very likely cause problems. Notice I wrapped it
in brackets, but even doing that is not always an assurance it will work
correctly.
Hi, I am trying to create a list from a the query that will be ran
frequently, it is supposed to show employees on the list that are have dates
[quoted text clipped - 7 lines]
Where Date >=DateSerial(Year(Date()),Day(Date()),1) And <DateSerial(Year(Date
()),Day(Date())+1,30)
 
M

Mitchell_Collen via AccessMonster.com

Thanks for the help!
Misty

Jerry said:
You're trying too hard. :)

Between Date() - 30 and Now()

I used Now() as it will include records up to the minute.

Oh! You're field named "Date" in the EmpRec table could be a problem. Date()
is a reserved word in Access. Therefore your Date field could be getting
confused with the Date function.
Hi, I am trying to create a list from a the query that will be ran
frequently, it is supposed to show employees on the list that are have dates
[quoted text clipped - 7 lines]
Where Date >=DateSerial(Year(Date()),Day(Date()),1) And <DateSerial(Year(Date
()),Day(Date())+1,30)
 

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

Top