0

I have a WPF C# Form and I'm trying to default 2 DatePickers to the current Week,

For example, I have fromDate and toDate, I'd like for fromDate to be the beginning of the week and toDate to be the end of the week.

How would I be able to do this with WPF C# Form

Sandro Perez
  • 120
  • 1
  • 11

1 Answers1

1

If you are looking how to choose the start and end days of a week given a single date see: How can I get the DateTime for the start of the week?

Using the code in the referenced question you can do

DateTime dtStart = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
DateTime dtEnd = dtStart.AddDays(6);
Community
  • 1
  • 1
Tim
  • 606
  • 4
  • 7