Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Sunday, February 19, 2012

Converting unix time (PLEASE HELP!)

Oh please put me out of my misery and help me … I am pulling dates from my database which are in unix time. This means the time is displayed as seconds since 01/01/1970. I am trying to convert this to a date so I can create parameters for my report.

I have tried using convert and dateadd but nothing seems to work.

Any ideas?

Have you triedthis

converting unix dates

Hi,
Does anyone know of a quick an easy way of convertiing unix date serials eg
12815 to March 31 2005).
Any pointers appreciated
Thanks
SimonHi
I would have expected
select dateadd(ss, <UNIX_timestamp>, '19700101')
to have worked which implies 12815 either wrong or not a unix timestamp!!
John
"skilla31" wrote:

> Hi,
> Does anyone know of a quick an easy way of convertiing unix date serials e
g
> 12815 to March 31 2005).
> Any pointers appreciated
> Thanks
> Simon
>
>|||I suspect this isn't a standard Unix timestamp. Maybe 12815 represents
the number of days since some date. For example:
DECLARE @.t INTEGER
SET @.t = 12815
SELECT DATEADD(DAY,@.t,'19691231')
Result:
2005-01-31 00:00:00.000
(1 row(s) affected)
or:
SELECT DATEADD(DAY,@.t,'19700228')
Result:
2005-03-31 00:00:00.000
(1 row(s) affected)
DATEADD is probably the function you need in any case.
David Portas
SQL Server MVP
--|||Thanks
Jens, John & David, that solved my problem. Turns out I got the number wrong
should've been 12873
Thanks
Simon
"skilla31" <simon@.ris.org.uk> wrote in message
news:uN56AxOQFHA.3496@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Does anyone know of a quick an easy way of convertiing unix date serials
> eg 12815 to March 31 2005).
> Any pointers appreciated
> Thanks
> Simon
>|||"skilla31" <simon@.ris.org.uk> wrote in message
news:uN56AxOQFHA.3496@.TK2MSFTNGP12.phx.gbl...

> Hi,
> Does anyone know of a quick an easy way of convertiing unix date serials
> eg 12815 to March 31 2005).
SELECT DATEADD(d, 12815, '01 Jan 1970')