DateTime转换失败,后继插入SQL Server记录 [英] DateTime conversion failed with sequelise inserting a SQL Server record
本文介绍了DateTime转换失败,后继插入SQL Server记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将新记录添加到数据库中时,出现错误消息:
When adding a new record into my database I get the error:
从字符串转换日期和/或时间时转换失败
Conversion failed when converting date and/or time from character string
它尝试插入的datetime
是:
2015-10-05 21:43:57.000 +00:00
似乎Sequelise也插入了时区.
It seems that Sequelise also inserts the timezone.
我尝试将时区"设置为空字符串,但这无济于事.
I tried setting the "timezone" to an empty string but this didn't help.
如何通过续集插入有效的SQL Server DATETIME
?
How can I insert a valid SQL Server DATETIME
with sequelize?
型号:
RegDate : {
type : Tedious.TYPES.DateTime,
defaultValue: Sequelize.NOW
}
推荐答案
将DB中的Column数据类型从DateTime更改为DateTime2
Change the Column data type in the DB from DateTime to DateTime2
-- This will fail
begin tran
CREATE TABLE #Temp1 ( CTECol datetime );
insert into #Temp1 select '2015-10-05 21:43:57.000 +00:00'
rollback
-- This will Success
begin tran
CREATE TABLE #Temp1 ( CTECol datetime2 );
insert into #Temp1 select '2015-10-05 21:43:57.000 +00:00'
rollback
这篇关于DateTime转换失败,后继插入SQL Server记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文