Use DateTime. DayOfWeek property to display the current day of week. DayOfWeek wk = DateTime.
Use the DateTime. DayOfWeek or DateTimeOffset. DayOfWeek property to retrieve a DayOfWeek value that indicates the day of the week.
The Weekday returns an integer representing the day of week, starting from 1=Sunday. WeekdayName functions starts the week as Monday=1.
C# DayOfWeekUse the DayOfWeek enum type, which contains Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. DayOfWeek. 7 days are in each week. In C# programs we can determine if a certain date is a Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday.
Use
day1 = (int)ClockInfoFromSystem.DayOfWeek;
int day = (int)DateTime.Now.DayOfWeek;
First day of the week: Sunday (with a value of zero)
If you want to set first day of the week to Monday with integer value 1 and Sunday with integer value 7
int day = ((int)DateTime.Now.DayOfWeek == 0) ? 7 : (int)DateTime.Now.DayOfWeek;
day1= (int)ClockInfoFromSystem.DayOfWeek;
Try this. It will work just fine:
int week = Convert.ToInt32(currentDateTime.DayOfWeek);
The correct way to get the integer value of an Enum such as DayOfWeek as a string is:
DayOfWeek.ToString("d")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With