Click here to Skip to main content
15,792,364 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

date is stored in string type variable strdate.
how to covert strdate to date format.

than you
vinay gowda

Try the DateTime.TryParse[^] or DateTime.TryParseExact[^] methods.
Share this answer
Mehdi Gholam 4-Nov-11 2:51am    
Abhinav S 4-Nov-11 4:14am    
Thank you Mehdi.
Dim convertedDate As Date = Date.Parse(strdate)
Share this answer
Abhinav S 4-Nov-11 4:15am    
Yes that is correct as well. However, TryParse and TryParseExact are safer methods if you are not sure if the string is actually a date. My 5.
Share this answer
DateTime.TryParseExact will parse your string exactly to convert it to dateTime format. Just pass the needed datetime format and you will get parsed string.
here is example.
Dim enUS As New CultureInfo("en-US") 
dateString = "5/01/2009 09:00"
Date.TryParseExact(dateString, "M/dd/yyyy hh:mm", enUS,DateTimeStyles.None, dateValue)
Share this answer
Abhinav S 4-Nov-11 4:16am    
Similar to my answer but with example. 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900