【发布时间】:2018-12-05 10:42:18
【问题描述】:
我有一个带有时区的日期时间格式的特定字符串。我需要使用 TimeZone 将字符串转换为 DateTime,并对其进行处理并转换为 UTC 时间。
DECLARE @T AS VARCHAR(100)
SET @T = '2018-12-04T10:23:34+05:30'
SELECT CONVERT(DATETIME,@T,127),CONVERT(DATETIME,@T) AT TIME ZONE 'UTC'
结果
Msg 241, Level 16, State 1, Line 3
Conversion failed when converting date and/or time from character string.
我也尝试过不使用转换参数 127 但仍然返回相同的错误。
【问题讨论】:
标签: sql-server tsql type-conversion azure-sql-database datetime-format