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

different date criteria for days of week

Status
Not open for further replies.

Amanda2

Technical User
Aug 3, 2004
4
US
I need to get records based on a range of dates that change depending on when I am running the query.

ie: If I run it on Monday I need records with dates from between 10 and 16 days ago; if I run it on Tuesday, I need records with dates from between 11 and 17 days ago...

DateAdd does not seem to work with "Between x And y".

Any suggestions? I'm pulling hair out.
 
Sounds to me as though you are wanting to specify a specific week and ignore the individual days of that week.
That way it doesn't matter when you run the query!

Look up formatting dates in the Help!

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
And what about this ?
WHERE [date field] BETWEEN (Date()-15-Int(Format(Date()+3,"w",2))) AND (Date()-9-Int(Format(Date()+3,"w",2)))
Or this ?
WHERE (Date()-[date field]-Int(Format(Date()+3,"w",2))) BETWEEN 9 AND 15

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks Frank, you're right! Now I just have to figure out the week functions.

DateAdd("w",-2,[DateField]) ???

 
Something like this ?
WHERE Format([DateField],"ww")=Format(DateAdd("ww",-2,Date),"ww")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top