Day of week to integer


How can I convert day of week to integer?

i.e. monday = 1
tuesday =2

C# code:

string myDay = “Tuesday”;
int dayNumber = ((int)Enum.Parse(typeof(DayOfWeek), myDay));

VB.Net code:

Dim myDay As String = "Tuesday"
Dim dayNumber As Integer = (CInt([Enum].Parse(GetType(DayOfWeek), myDay)))
1 Like

Could you show an example please?

1 Like

Kindly use a assign activity
And mention like this
Out_week = Convert.ToInt32(DateTime.Now.DayOfWeek)

Where Out_week is a variable of type int32
— now use a write line activity and mention like this
Where we will be getting 0 for Sunday, 1 for Monday,…

For more details on this
Microsoft has given a document and we can achieve this with simple assign activities

Hope this would help you
Kindly try this and let know for any queries or clarification

Cheers @bhe98

You have to use just two assign activities.

Declare two variables -

myDay as String type
dayNumber As Integer

Assign Activity, myDay = “Monday”
Assign Activity, dayNumber = (CInt([Enum].Parse(GetType(DayOfWeek), myDay)))

Use MessageBox to display dayNumber which displays 1.

Karthik Byggari

Thanks guys

1 Like

No worries
Cheers @bhe98

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.