Showing posts with label convert a string to date without time. Show all posts
Showing posts with label convert a string to date without time. Show all posts

Friday, December 28, 2012

Convert string to date in c#

Below code shows how to convert string which has both date and time to just the date without time.

string value = "1/1/2012 08:15:20";

DateTime dt = Convert.ToDateTime(value);
string shortDate = dt.ToShortDateString();