How can I get DateTime value in C# from row, the current code is giving me error
any help is appreciated, the data is coming in from progress database:
foreach (DataRow r in ds.Tables[0].Rows)
{
string prodCode = r["PRD-CDE"].ToString();
string statCode = r["STAT"].ToString();
DateTime firstIssueDate = DateTime.Parse((r["FISS"]).ToString());
DateTime endIssueDate = DateTime.Parse((r["EISS"]).ToString());
if(endIssueDate > DateTime.Now)
{ /*do some thing...*/}
else {/*user invalid...*/}
}
This should compile and may work for you. Though it is certainly not performing any error checking that you should do for production code. Also look into DateTime.TryParse and you may to look into adding a IFormatProvider to ensure the format is parsed as expected.