Need Help with date calculations!!!

A

anitra_tanner

I have an orders table, I am tryin to write a query that will use the
Order Date (O_Date) for calculating orders with dates 7 days previous,
the date in the O_Date field.

In the criteria
I have used Date() -7 but I still get future dates in my results

I have also used DateAdd("d", 7, Date()) and DateAdd("d", -7, Date())
and many other versions of the 2. <,> etc...

I also need dates 1 month before and after today's date. Any
suggestions?
 
D

Douglas J. Steele

I have an orders table, I am tryin to write a query that will use the
Order Date (O_Date) for calculating orders with dates 7 days previous,
the date in the O_Date field.

In the criteria
I have used Date() -7 but I still get future dates in my results

BETWEEN Date() - 7 AND Date()

or

BETWEEN DateAdd("d", -7, Date()) AND Date()
I also need dates 1 month before and after today's date. Any
suggestions?

BETWEEN DateAdd("m", -1, Date()) AND DateAdd("m", 1, Date())

Note that if O_Date has time in it (because you used the Now() function to
populate it, rather than the Date() function), you'll want to increase the
end date in both cases:

BETWEEN Date() - 7 AND Date() + 1

and

BETWEEN DateAdd("m", -1, Date()) AND DateAdd("m", 1, Date()) + 1
 

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

Similar Threads

Calculated Field in Query - Date Format 5
Excel Help with dates 2
Monday-Sunday Date Range 2
Help with small result type 2
DateDiff returning incorrect years 11
Multi table query 1
Date Range Issue 3
Sorted and Unique Date Period 2

Top