Link to home
Start Free TrialLog in
Avatar of arichexp
arichexp

asked on

Getting previous week's date range

How would I write a function that returns the previous week's date range?  For instance, if the run date is Monday 3/18/2002, it'll return "3/10/2002 - 3/16/2002."
Avatar of Bahnass
Bahnass
Flag of Egypt image

TRY THIS
DEBUG.PRINT  (DATE - WEEKday(date)),(DATE - WEEKday(date)-7)
ASKER CERTIFIED SOLUTION
Avatar of bill02
bill02

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bill02
bill02

label1.caption = DateAdd("d", -7, Format(Now, "mm/dd/yyyy")) & " - " &  DateAdd("d", 7, Format(Now, "mm/dd/yyyy"))

sorry
Avatar of arichexp

ASKER

But what if the run date is any day of the week, not just Monday?
this should do what you need replace now with your dates and format them ass you  wish



Label1.Caption = DateAdd("d", (-(Weekday(Now) - 1)), Now) & " - " & DateAdd("d", (7 - (Weekday(Now))), Now)
im sooooooo sorry i did not mean ass i as sorry
Did U C MY POST


DEBUG.PRINT  (DATE - WEEKday(date)),(DATE - WEEKday(date)-7)

1     Date     returns current date
2     WeekDay returns a number of day in week  

So please try it

pls give feedback  ( if U need to reject Bill answer U can do it simply )

Thanks, although I modified it slightly for a datetime field, i.e.

date_beg = Date - Weekday(Date) - 6 & " 00:00:00"
date_end = Date - Weekday(Date) & " 23:59:59"
Thanks Bahnass!
arichexp

Where is my Points !!!!!

WeekDay from beginning !!!!!
For some reason, the points went to bill02, even though I accepted your comment as the answer.  Is there a bug of somekind?