DateTime issue in SQL Server

后端 未结 5 889
我在风中等你
我在风中等你 2021-01-18 22:08

I\'m trying to do an INSERT into an already set DB in MS SQL Server, the DB server is in a shared hosting (godaddy).

And what i\'m trying to achieve is to store an a

5条回答
  •  死守一世寂寞
    2021-01-18 22:25

    I cant understand why you are converting a datetime into String ??

     datetime.Text = DateTime.Now.ToString("yyyyMMddHHmmss");
    

    if you have to insert datetime in your DB then just pass that datetime variable to insert command.

    DateTime dt = new DateTime();
    dt = DateTime.Now.Date;
    

    When you will insert it to DB, DB will convert it to its appropriate datetime format. Just try it.

提交回复
热议问题