MSSQL | Convert unix timestamp to date

select dateadd(ss, {field_name}, '19700101')

2 Responses to “MSSQL | Convert unix timestamp to date”

  1. Bev Scott Says:

    When I use the following function.

    The date is one day ahead of what it should be.
    It does not show any time.

    SELECT DATEADD(SECOND, 1179367200, '19700101') as realdate

    returns
    2007-05-17 02:00:00.000

    the date and time should be
    2007-05-16 7:00 pm

    select dateadd(ss, {field_name}, ‘19700101′)

    Can anyone help me with this.

  2. simone Says:

    Hello. Why do you say that

    SELECT DATEADD(SECOND, 1179367200, ‘19700101′) as realdate

    should returns 2007-05-16 7:00 pm ?

    If I convert 1179367200 I get Thu, 17 May 2007 04:00:00 +0200

Leave a Reply

Yes !