deadpool_Y7
deadpool_Y7

Reputation: 139

Datetime get start and enddate of next week

I have a small calendar application where you can see all workingdays of the current week. Now I added some buttons to swap weeks on and weeks back.

var monday = DateTime.Now.AddDays(DayOfWeek.Monday - DateTime.Now.DayOfWeek)//22.02.16
var friday = DateTime.Now.AddDays(DayOfWeek.Friday - DateTime.Now.DayOfWeek)//26.02.16

I want to get next monday and next friday of next week so the variable nextMonday and nextFriday should be:

var nextMonday = //29.02.16
var nextFriday = //04.03.16

Upvotes: 0

Views: 688

Answers (1)

juharr
juharr

Reputation: 32266

Should be as simple as using DateTime.AddDays to add 7 days.

var nextMonday = monday.AddDays(7);
var nextFriday = friday.AddDays(7);

Upvotes: 1

Related Questions