how to get today day's name

Posted by Shanky11 under VB.NET on 2/20/2013 | Points: 10 | Views : 7853 | Status : [Member] | Replies : 3
I have to fetch today day name like wednesday ????????? i hv written this code but it shows tuesday only ysterday i had written this code it shows the same days name event today

Dim d As Date = New Date
Dim day As Integer
day = d.Day()

Select Case day
Case "0"
MessageBox.Show("Today is Monday")

Case "1"
MessageBox.Show("Today is Tuesday")
Case "2"
MessageBox.Show("Today is Wednesday")
Case "3"
MessageBox.Show("Today is Thursday")
Case "4"
MessageBox.Show("Today is Friday")
Exit Select
End Select




Responses

Posted by: Kundan64 on: 2/20/2013 [Member] Starter | Points: 25

Up
0
Down
HI Shanky,
If you want to Show the Date Name then try this.
Dim dayName As String = DateTime.Now.ToString("dddd")


It will give the DayName (Sunday, Monday.....) for the current date, You can change the DateTime value with your desire DateTime.

Thanks
Kundan

Mark as answer if it helps you.


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 2/20/2013 [Member] Starter | Points: 25

Up
0
Down
Dim dt as Datetime=Datetime.Now.DayOfWeek

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 2/22/2013 [Member] [MVP] Gold | Points: 25

Up
0
Down
Try this,

Dim day As Integer = Date.Today.DayOfWeek
Select Case day
Case "1"
Response.Write("Today is Monday")
Case "2"
Response.Write("Today is Tuesday")
Case "3"
Response.Write("Today is Wednesday")
Case "4"
Response.Write("Today is Thursday")
Case "5"
Response.Write("Today is Friday")
Exit Select
End Select

Please Mark As Answer if this helps you.

.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response