Convert DateTime in DataRow to a formatted date string

前端 未结 2 1179
星月不相逢
星月不相逢 2020-12-21 21:47

I\'m hoping that there is something I am not seeing clearly, but to simplify, I have the below code

foreach (DataRow row in dt.Rows)
{
  row[\"StartOn\"] = C         


        
2条回答
  •  情书的邮戳
    2020-12-21 22:15

    StartOn is apparently a DateTime type. DateTime types do NOT have a format. They are an object that specifies year, month, date, and time (among other things). All you are doing in your conversions is stripping out the time so that the new datetime has a time of 12:00 am.

提交回复
热议问题