Hi all,
i want get the first day of the week from today date. How can i do this?
Thank's
Printable View
Hi all,
i want get the first day of the week from today date. How can i do this?
Thank's
hi,Quote:
Originally Posted by dewoul
Do you mean how to get the first date of the current week?
this assumes that sunday is first day of week. If you want to have monday as first day:Code:System.DateTime today = System.DateTime.Now;
int dayOfWeek = (int)today.DayOfWeek;
System.DateTime firstDayOfWeek = today.Subtract(new TimeSpan(dayOfWeek, 0, 0, 0));
Regards,Code:System.DateTime today = System.DateTime.Now;
int dayOfWeek = (int)today.DayOfWeek-1;
if (dayOfWeek ==-1)
dayOfWeek = 7;
System.DateTime firstDayOfWeek = today.Subtract(new TimeSpan(dayOfWeek, 0, 0, 0));
Laitinen
The method DayOfWeek of DateTime object
Code:DateTime current = DateTime.Now;
MessageBox.Show(current.DayOfWeek.ToString());
This does not get the first day of week. See post #2.Quote:
Originally Posted by Talikag
Regards,
Laitinen