Conversion failed when converting date and/or time from character string while inserting datetime

后端 未结 15 1593
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 09:34

I was trying to create a table as follows,

create table table1(date1 datetime,date2 datetime);

First I tried inserting values as below,

15条回答
  •  孤独总比滥情好
    2020-11-22 10:04

    This is how to easily convert from an ISO string to a SQL-Server datetime:

    INSERT INTO time_data (ImportateDateTime) VALUES (CAST(CONVERT(datetimeoffset,'2019-09-13 22:06:26.527000') AS datetime))
    

    Source https://www.sqlservercurry.com/2010/04/convert-character-string-iso-date-to.html

提交回复
热议问题