0

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Chrismage
  • 109
  • 1
  • 2
  • 9

2 Answers2

2

Try this:

DECLARE @Input int = 1442998800
SELECT dateadd(second, @Input, '1970-01-01 03:00:00')

see fiddle here.

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.

Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
1

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 ;-)

CeOnSql
  • 2,615
  • 1
  • 16
  • 38