【问题标题】:Insert UTC date in Date type column在日期类型列中插入 UTC 日期
【发布时间】:2020-10-07 17:13:22
【问题描述】:

我想在我的 SQL Server 表日期类型中插入 UTC 日期,我的查询失败了,这是我的失败

Insert into Vendor(Vendor_id,Vendor_Name,LIC_START_DATE) 
             VALUES('12345','XYZ','2020-01-01Z');

LIC_START_DATE 是日期类型。

你能帮忙吗?

【问题讨论】:

  • “它失败了”是什么意思 - 它是否给出错误?不出现?出现错误?请澄清。

标签: sql-server date utc


【解决方案1】:

代替

Insert into Vendor(Vendor_id,Vendor_Name,LIC_START_DATE) 
             VALUES('12345','XYZ','2020-01-01Z');

试试

Insert into Vendor(Vendor_id,Vendor_Name,LIC_START_DATE) 
             VALUES('12345','XYZ','2020-01-01');

关于一般的 UTC 日期/日期时间:

获取当前 UTC 日期:

select getutcdate();

获取当前 UTC datetime2(7)

select sysutcdatetime()

将特定时区中的现有日期时间转换为 UTC 日期时间

declare @existing_date          datetime='2001-01-01 10:00:00';

select @existing_date at time zone 'Eastern Standard Time' at time zone 'UTC';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-17
    • 2018-03-10
    • 2021-02-03
    • 2015-06-09
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多