forum

Home / DeveloperSection / Forums / how to parse out date time from a string and match with a given format

how to parse out date time from a string and match with a given format

Anonymous User 1908 12-Dec-2013

My datetime value is stored in the column as 12/03/2013 12:00 am, I am trying to parse out the date from a different column which is a string so i check to see if the datetime is a valid date. I can not figure out the format, yyyy-mm-dd hh:mm tt doesnt seem to make the condition true.

string[] format = new string[] { "yyyy-mm-dd hh:mm tt" };

DateTime datetime;

//12/03/2013 12:00 am

if (DateTime.TryParseExact(userFilters.FilterValue, format, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out datetime))

{

  DateEntered = datetime;

}


c# c# 
Updated on 12-Dec-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By