Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the integer value of day of week

People also ask

How to get day of the week in c#?

Use DateTime. DayOfWeek property to display the current day of week. DayOfWeek wk = DateTime.

How to get day of week in vb net?

Use the DateTime. DayOfWeek or DateTimeOffset. DayOfWeek property to retrieve a DayOfWeek value that indicates the day of the week.

How to get day name from Date in vb net?

The Weekday returns an integer representing the day of week, starting from 1=Sunday. WeekdayName functions starts the week as Monday=1.

What is DayOfWeek C#?

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")