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

Query for yesterdays data 1

Status
Not open for further replies.

RJL1

Technical User
Oct 3, 2002
228
US
I have a query that querys our history table. This table has all the orders we have shipped. I can produce a query that shown all orders ever shipped and the dates. My problem is getting a query that only shows the yesterdays orders. I was trying to use Date()-1 in the critiria but I get no results. What piece is missing to complete my query?

Thanks
Ricardo
 
try this on your date range criteria,

WHERE [Your Date Field] >= Date()-1 And [Your Date Field] < Date()

...this syntax WILL give you yesterday only...the reason for the above syntax....date()-1 will not work because of the DATE/TIME factor

if the field you're querying is a date/time field use the below explanation.

Query Logic Explained:

=Date()-1 WRONG WAY
LOOKS AT 10/14/2002 Only

>=Date()-1 And <Date()CORRECT WAY
LOOKS AT 10/14/2002 12:00:00 AM to 10/14/2002 11:59:59 PM
 
Perhaps an easier way might be to use the DateAdd function?

= DateAdd(&quot;d&quot;,-1,Date()) Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Thanks this worked out great.

I used THEGREEK's method I coul not get the second one to produce data

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top