[SQL Server] Unix Timestamp to datetime

inno
2024-02-02 09:01 229 0
[SQL Server] Unix Timestamp to datetime

DECLARE @UnixTimestamp bigINT, @LocalTimeOffset  bigINT;
 
SET @UnixTimestamp = 1706829780000/1000;
SET @LocalTimeOffset = DATEDIFF(second,GETUTCDATE(),GETDATE());
 
SELECT dateadd(second, (@UnixTimestamp + @LocalTimeOffset), '1970-01-01') at time zone 'Tokyo Standard Time';

コメント