Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting DayOfWeek enum to a string repesenting the day

I was wondering if there was a way to directly convert the integer DayOfWeek returns into a string representing the day like Monday, Tuesday etc.

Sample code:

MessageBox.Show(Date.Today.DayOfWeek)

This will return 6 (as of today). Is there a way to directly convert this into Saturday, for example? I don't really care what it really converts it into, but I want to do away with my Select Case:

Select Case Date.Today.DayOfWeek
     Case 0
         day = "Sunday"
     Case 1
         day = "Monday"
     Case 2
         day = "Tuesday"
     Case 3
         day = "Wednesday"
     Case 4
         day = "Thursday"
     Case 5
         day = "Friday"
     Case 6
         day = "Saturday"
     Case Else
         day = "Apocalypse: we're all boned."
 End Select

Thanks :)

like image 948
James Avatar asked Jan 30 '10 19:01

James


1 Answers

DateTimeFormatInfo.CurrentInfo.GetDayName.

like image 103
itowlson Avatar answered Sep 28 '22 22:09

itowlson