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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving dates on in a query...

Status
Not open for further replies.

Ben6550

Technical User
Jan 8, 2004
16
GB
Hi,

I have created a query within access 2002 which pulls out the data i require for that day. How can i programme the query so it searches for the real-time date each day it is run without having to goto into the query and changing the date within the criteria??
 
Ben:

Use the Access function Date() in the criteria cell.

That will pull all the records with today's date.

If you want to adjust the date down just subtract the number of days necessary.

For example, to get yesterday's date use Date() -1.

hth

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Larry,

Have you ever seen this date function cause an ODBC error?

When I use Date()-1 in my criteria it causes an ODBC error, however when I remove the criteria the query runs perfectly fine.

Any help would be appreciated.

 
To get yesterdays data i used the dateadd function

DateAdd("d",-1,date())

Many times without error
 
educate:

Are you querying an SQL or some other, non-Access, database?

Try Tom Adams suggestion and see if that will work for you. Tom's way, since it uses the proper function, is a better approach than mine. I tend to be lazy sometimes.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top