In ASP.Net to convert string into DateTime you can use Convert.ToDateTime function in VB. Further you can also format the output of Date or Time according to your requirement, using different VB Format Date patterns such as MM/dd/yyyy, dd-mm-yyyy etc.
First of all create a string variable to store the string type DateTime.
Dim myDateTimeString As String
Then create a new variable of type DateTime and pass the string to DateTime variable using Convert.ToDateTime function.
Dim dt As DateTime
dt = Convert.ToDateTime(myDateTimeString)
Convert.ToDateTime function accepts the string value and returns the Date Type value.
Now you are ready to get the different parts of the Date String passed to the DateTime variable.
Response.Write(dt.Day & "/" & dt.Month & "/" & dt.Year) Response.Write("<br>") Response.Write(dt.ToString("dddd"))
Response.Write("<br>")
Response.Write(dt.ToString("MMMM"))
Output
22/7/2008 Tuesday July
Further you can format the DateTime using ToString("xxxxxxxxxx").
Click here to learn ASP.Net VB Format DateTime using ToString Function
Currently rated 5.0 by 1 people
Tags: asp.net 2.0, asp.net convert string to date, vb datetime, vb tostring function, asp.net datetime, vb convert string to date, vb current datetime, asp.net datetime format, free source code, c# datetime, asp.net vb datetime, asp.net c# datetime, asp.net vb tostring function, asp.net format date, convert.todatetime function
7/19/2008 10:07:57 PM
thanks....
eldhose
8/23/2008 8:40:39 PM