I'm trying to convert the following command:
to_char(to_date('01/01/1970 00:00:00', 'MM/DD/YYYY HH24:MI:SS')+((1442998800)/( 60 * 60 * 24 )+(180/1440)),'DD/MM/YYYY HH24:MI:SS')
But with no success, any help is greatly appreciated
Many thanks
I'm trying to convert the following command:
to_char(to_date('01/01/1970 00:00:00', 'MM/DD/YYYY HH24:MI:SS')+((1442998800)/( 60 * 60 * 24 )+(180/1440)),'DD/MM/YYYY HH24:MI:SS')
But with no success, any help is greatly appreciated
Many thanks
Try this:
DECLARE @Input int = 1442998800
SELECT dateadd(second, @Input, '1970-01-01 03:00:00')
Explenation: it's clear that the input is the number of seconds since a specific date - turns out that date is January first, 1970, at 3 am.
This works for me:
SELECT FORMAT(DATEADD(SECOND,1442998800,'1970-01-01'),'dd/MM/yyyy hh:mm:ss')
In words' it adds 1442998800 seconds to 1970-01-01 and formats it the way you decsribed. Give it a try ;-)