Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying 30 days back in Access 1

Status
Not open for further replies.

jbelf

MIS
May 14, 2003
12
0
0
AU
Hi,

Trying to create a query from a 'start date' field, which brings records back listed 30 days back from the current date. I thought the syntax was 'now-30', but it apparently is not.

Date()-30 brings back records that are exactly 30 days old, but I need all records in the past 30 days.

any help is greatly appreciated!

 
Try this:

WHERE tblYourTableName.[StartDate]< DateAdd(&quot;d&quot;,-30,Date());


You can use the expression Date() - 30 but I always use DateAdd as I have seen erroneous results by just subtracting and integer value from the Date function.

Post back with questions.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
If you wish to use the DATE()-30, you can use:

BETWEEN DATE()-30 AND DATE()

This will give you the date range between 30 days ago and today.
 
Whoo hoo! two different forums, 6 replies and joebrens was the only one that worked for me.

Thanks!
 
Sorry, misread your post initially:

WHERE tblYourTableName.[StartDate]>= DateAdd(&quot;d&quot;,-30,Date());

This should also do it. I thought initially you wanted to return records that were over 30 days old.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top