DateTime format to SQL format using C#

前端 未结 15 1227
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 02:47

I am trying to save the current date time format from C# and convert it to an SQL Server date format like so yyyy-MM-dd HH:mm:ss so I can use it for my UP

15条回答
  •  借酒劲吻你
    2020-11-28 03:08

    Your first code will work by doing this

    DateTime myDateTime = DateTime.Now;
    string sqlFormattedDate = myDateTime.ToString("yyyy-MM-dd HH:mm:ss"); //Remove myDateTime.Date part 
    

提交回复
热议问题