user1764540
user1764540

Reputation: 77

how to have weekly dates

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

Answers (1)

Derek Tomes
Derek Tomes

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

Related Questions