Users Pricing

forum

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

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

Anonymous User 2324 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;

}


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md