Retrieving a DateTime value from a DataRow (C#)

后端 未结 8 1389
别跟我提以往
别跟我提以往 2020-12-09 04:06

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:

8条回答
  •  时光取名叫无心
    2020-12-09 04:38

    I would recommend using DateTime.Parse() if the row is returning a string for that index.

     string prodCode = r["PRD-CDE"].ToString(),statCode = r["STAT"].ToString();
     DateTime firstIssueDate = DateTime.Parse(r["FISS"].ToString());
     DateTime endIssueDate = DateTime.Parse(r["EISS"].ToString());
    

    You could also use TryParse depending on your needs.

提交回复
热议问题