System.DateTime SelectedDate = Today;
System.DateTime FirstDayOfWeekDate = SelectedDate.AddDays(SelectedDate.DayOfWeek * -1);
System.DateTime LastDayOfWeekDate = FirstDayOfWeekDate.AddDays(6);
System.DateTime FirstDayOfMonthDate = new System.DateTime(SelectedDate.Year, SelectedDate.Month, 1);
System.DateTime LastDayOfMonthDate = new System.DateTime(SelectedDate.Year, SelectedDate.Month, System.DateTime.DaysInMonth(SelectedDate.Year, SelectedDate.Month));
System.DateTime FirstDayOfYearDate = new System.DateTime(SelectedDate.Year, 1, 1);
System.DateTime LastDayOfYearDate = new System.DateTime(SelectedDate.Year, 12, System.DateTime.DaysInMonth(SelectedDate.Year, 12));
int DaysInTheYear = new System.DateTime(SelectedDate.Year, 12, System.DateTime.DaysInMonth(SelectedDate.Year, 12)).DayOfYear;
Calculate first and last day of week, month, year
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment