简体   繁体   中英

How to convert unix epoch format date to UTC in SQL query?

我的日期时间格式为 1610382439。我正在寻找 sql 查询将其转换为 UTC 时间。

One solution is to add those seconds to 1970-01-01. The datetime datatype does not adjust for DST:

select cast('1970-01-01' as datetime) + interval 1610382439 second
-- 2021-01-11 16:27:19

In SQL server and .net world it called ticks. You can take a look at this link which shows how to convert it: Convert .NET Ticks to SQL Server DateTime

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM