PDA

View Full Version : Need help with a date function.



OdiN
08-02-2007, 08:28 AM
Here is what I'm trying to do.

I need a function which takes the current day and finds the date of that weeks Sunday.

Then I need to take that date (of the Sunday) and subtract 13 weeks from it.

This is for the criteria in a query so that the only data displayed will be the previous 13 weeks worth.

Not quite sure how to go about this. TIA for the help.

Cosmos75
08-02-2007, 09:40 AM
To get Sunday's date.

DateAdd("d",-(DatePart("w",Date(),1,1)-1),Date())
Then use that to subtract 13 weeks.

DateAdd("ww",-13,DateAdd("d",-(DatePart("w",Date(),1,1)-1),Date()))

OdiN
08-02-2007, 10:31 AM
Thanks...Here is what I'm using finally:

Between DateAdd("ww",-13,DateAdd("d",1-Weekday(Date(),1),Date())) And DateAdd("d",1-Weekday(Date(),1),Date())

Cosmos75
08-02-2007, 10:33 AM
OdiN, Glad I could help!
:cool:

EDIT: Just noticed you found an easier way! :o:
:thumb