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."
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
label1.caption = DateAdd("d", -7, Format(Now, "mm/dd/yyyy")) & " - " & DateAdd("d", 7, Format(Now, "mm/dd/yyyy"))
sorry
sorry
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)
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 )
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 )
ASKER
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"
date_beg = Date - Weekday(Date) - 6 & " 00:00:00"
date_end = Date - Weekday(Date) & " 23:59:59"
ASKER
Thanks Bahnass!
arichexp
Where is my Points !!!!!
WeekDay from beginning !!!!!
Where is my Points !!!!!
WeekDay from beginning !!!!!
ASKER
For some reason, the points went to bill02, even though I accepted your comment as the answer. Is there a bug of somekind?
DEBUG.PRINT (DATE - WEEKday(date)),(DATE - WEEKday(date)-7)