Reputation: 77
How can we calculate the date for Monday in the past week. I am using asp and VB.net. Are there any date function. WE do have NOW in VB. But I want to know How we calculate the date for Monday in the past week. An example would like today is 1/31/2013 and the day is Thursday and I want the date for 1/21/2013 Monday. How will I do it
Upvotes: 0
Views: 129
Reputation: 4007
I'm not sure exactly what you want, but try this:
Public Function GetMondayLastWeek() As Date
Return DateAdd(DateInterval.Day, -Now.DayOfWeek + 1, Now.Date)
End Function
or this:
Public Function GetMondayLastWeek() As Date
Return DateAdd(DateInterval.Day, -Now.DayOfWeek + 8, Now.Date)
End Function
Upvotes: 1