Dear Madam/Sir,
Good day,
I have database in SQL server and there is column for time but in UNIX syntax, I tried to convert it and it worked for me by this code :
Select
dateadd(S, [TIMESTAMP_S], '1970-01-01'),Value
From [table_Name]
but my main problem is when I am trying to get last 24 hours from table I cant get it after converting and I face error.
My code with converting and get last 24 hours is :
select DATEADD(ss, TIMESTAMP_S, '1970-01-01 00:00') AS ConvertedDate from Table_Name
where TIMESTAMP_S between dateadd(hour, -24, CURRENT_TIMESTAMP)
AND CURRENT_TIMESTAMP
error is :
Msg 8115, Level 16, State 2, Line 18
Arithmetic overflow error converting expression to data type datetime.
thanx in advanse.
What I have tried:
Convert Unix time code:
Select
dateadd(S, [TIMESTAMP_S], '1970-01-01'),Value
From [table_Name]
convert Unix time and get last 24 hours code:
select DATEADD(ss, TIMESTAMP_S, '1970-01-01 00:00') AS ConvertedDate from Table_Name
where TIMESTAMP_S between dateadd(hour, -24, CURRENT_TIMESTAMP)
AND CURRENT_TIMESTAMP