Google Search

Google
 

Friday, June 1, 2007

Date Time

Dim dtNow As DateTime = DateTime.Now

'Date OutPut : 6/1/2007 2:53:10 PM
Response.Write("
Date Time :" + dtNow)

'Long Date : Friday, June 01, 2007
Response.Write("
Long Date :" & dtNow.ToLongDateString())

'Short Date : 6/1/2007
Response.Write("
Short Date :" & dtNow.ToShortDateString())

'Long Time : 2:53:10 PM
Response.Write("
Long Time :" & dtNow.ToLongTimeString())

'Short Time : 2:53 PM
Response.Write("
Short Time :" & dtNow.ToShortTimeString())

'Day Of Week : Friday
Response.Write("
Day Of Week : " & dtNow.DayOfWeek.ToString)

'Day Of Year : 152
Response.Write("
Day Of Week : " & dtNow.DayOfYear.ToString)


Dim nowdayofweek As Integer = dtNow.DayOfWeek
Dim weekStartDate, weekEndDate As DateTime

weekStartDate = DateAdd("d", 0 - dtNow.DayOfWeek, dtNow)
weekEndDate = DateAdd("d", 6 - dtNow.DayOfWeek, dtNow)

'Displays first day of the week : 03/18/2007
Response.Write("
Start Date-->" & weekStartDate.ToString("MM/dd/yyyy"))

'Displays last day of the week : 03/24/2007
Response.Write("
End Date-->" & weekEndDate.ToString("MM/dd/yyyy"))

0 comments: