I am having this format of datetime 1610382439.I am looking sql query to convert it to UTC time.
Asked
Active
Viewed 760 times
0
-
The query will be different on different RDBMS, which one are you using? MySQL? PostgreSQL? Oracle? ...? – Joachim Isaksson Nov 08 '21 at 07:03
-
I am using sql as language and Mysql as the product – Saswat Ray Nov 08 '21 at 08:45
2 Answers
1
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

Salman A
- 262,204
- 82
- 430
- 521
-
I am getting error Parse exception at 'datetime' while running as sql query in azure databricks notebook – Saswat Ray Nov 08 '21 at 09:28
-
-
-
yes, this query works for me select cast('1970-01-01' as date) + interval 1610382439 second – Saswat Ray Nov 08 '21 at 09:39
-
0
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

Reza Akraminejad
- 1,412
- 3
- 24
- 38