Wish to know the date range of last week or next week? What about the current or last months start and end date? Here's how...
Dim startweek
Dim endweek
Dim lastweekstart
Dim lastweekend
Dim currentmonthstart
Dim currentmonthend
Dim lastmonthstart
Dim lastmonthend
Dim today
today = Date.Today
endweek = DateAdd(DateInterval.Day, 1, DateAdd(DateInterval.Day, 7 - DatePart(DateInterval.Weekday, today), today))
startweek = DateAdd(DateInterval.Day, -6, endweek)
lastweekend = DateAdd(DateInterval.Day, -1, startweek)
lastweekstart = DateAdd(DateInterval.Day, -6, lastweekend)
currentmonthstart = DateAdd(DateInterval.Day, -(DatePart(DateInterval.Day, today) - 1), today)
currentmonthend = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, currentmonthstart))
lastmonthstart = DateAdd(DateInterval.Month, -1, currentmonthstart)
lastmonthend = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, lastmonthstart))
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment