Home » Applications » Month, day and year code behind format

Month, day and year code behind format

Day name and date format of Friday, 11/11/2011

Dim strDayName As String
Dim curTime As New DateTime
                        
curTime = DateTime.Now.ToShortDateString()
strDayName = curTime.DayOfWeek.ToString

Response.Write(strDayName & ", " & DateTime.Today)

Result: Friday, 11/11/2011
Day name and date format of Friday, 11/11/2011 using case funtion

Dim iDay As String
Dim strDayName As String
iDay = DatePart("w", DateTime.Now)

   Select Case iDay
          Case "1"
              strDayName = "Sunday"
          Case "2"
              strDayName = "Monday"
          Case "3"
              strDayName = "Tuesday"
          Case "4"
              strDayName = "Wednesday"
          Case "5"
              strDayName = "Thursday"
          Case "6"
              strDayName = "Friday"
          Case "7"
              strDayName = "Saturday"
   End Select

Response.Write(strDayName & ", " & DateTime.Today)

Month name, day and year format of November 11, 2011

Response.Write(MonthName(DateTime.Now.Month) & " " & DateTime.Now.Day & ", 
                                                _" & DateTime.Now.Year)

Result: November 11, 2011

View related posts:
VB.NET – Date in code behind
VB.NET date and time format

2 Responses for Month, day and year code behind format

  1. […] – VB.NET – Date in code behind – Month, day and year code behind format […]

  2. […] Month, day and year code behind format – VB.NET date and time […]