Query - First day of the previous week & Last day of previous week

Flint

Registered User.
Local time
Today, 12:42
Joined
Mar 19, 2004
Messages
10
To set the criteria to show dates on the first day of the previous month:
DateSerial(Year(Date()), Month(Date())-1,1)

To set the criteria to show dates on the last day of the previous month:
DateSerial(Year(Date()), Month(Date()),0)



But what criteria do you enter into a query to show the first day of the previous week? And last day of the previous week?
 
Flint said:
But what criteria do you enter into a query to show the first day of the previous week? And last day of the previous week?


Well.. if we consider the following (taken from here )

The first day of the current week (assuming Sunday = day 1):
Date() - WeekDay(Date()) + 1

The last day of the current week:
Date() - WeekDay(Date()) + 7

We could just subtract 7 from each?
 
I think is:
DateAdd("ww", -1, Date).....Thats 1 week
DateAdd("ww", -2, Date)....Thats 2 weeks.
 
I think is:
DateAdd("ww", -1, Date).....Thats 1 week
DateAdd("ww", -2, Date)....Thats 2 weeks.
Correct, that's how you would get one/two week(s) prior to today's date but it doesn't answer the question. This is a rather old thread too.

So for the sake of clarity, using what o1110010 provided, to get the first day of the previous week you do this:
Code:
DateAdd("ww", -1, Date - Weekday(Date) + 1)
To get the last day of the previous week, this:
Code:
DateAdd("ww", -1, Date - Weekday(Date) + 7)
 

Users who are viewing this thread

Back
Top Bottom