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();

No comments:

Post a Comment