How to convert a SQL date to a DateTime?

前端 未结 3 1478
迷失自我
迷失自我 2020-12-16 18:53

I have a column with the date type in my SQL database. How can I convert it to C# DateTime and then back again to a SQL date?

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 19:38

     string mydate= Convert.ToDateTime(reader["dateColumn"]).ToShortDateString().ToString());
    

    These code is working for me.Try these one

提交回复
热议问题