Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6853717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:32:42+00:00 2026-05-27T01:32:42+00:00

How can I convert UNIX timestamp (bigint) to DateTime in SQL Server?

  • 0

How can I convert UNIX timestamp (bigint) to DateTime in SQL Server?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:32:43+00:00Added an answer on May 27, 2026 at 1:32 am

    This worked for me:

    Select
        dateadd(S, [unixtime], '1970-01-01')
    From [Table]
    

    In case any one wonders why 1970-01-01, This is called Epoch time.

    Below is a quote from Wikipedia:

    The number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970,[1][note 1] not counting leap seconds.

    The Year 2038 Problem

    Furthermore the DataAdd function takes an int for the seconds to add. So if you are trying to add more than 2147483647 seconds you’ll get an arithmetic overflow error. To resolve this issue you can break the addition into two calls to DateAdd one for the years and one for the remaining seconds.

    Declare @t as bigint = 4147483645
    
    Select (@t / @oneyear) -- Years to add
    Select (@t % @oneyear) -- Remaining seconds to add
    
    -- Get Date given a timestamp @t
    Declare @oneyear as int = 31622400
    Select DateAdd(SECOND, @t % @oneyear, DateAdd(YEAR, @t / @oneyear, '1970-01-01'))
    

    This will let you convert a timestamp that represents a year greater than 2038.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can convert SQL timestamp to unix timestamp, using the following way.
How can I convert from a unix timestamp (say 1232559922) to a fractional julian
How can you convert the UNIX timestamp (that is in the form of a
How can I convert time in unix timestamp to normal time?
How can I convert an NSDate to a Unix timestamp in Objective-C?
How can I convert a time string like this: 30/7/2010 to a UNIX timestamp?
On Linux you can convert a date like 2010-10-02 to a unix timestamp in
Is there a MySQL function which can be used to convert a Unix timestamp
I'm trying to convert a datetime object to a UNIX timestamp (preferably in milliseconds,
I have a problem in converting the Unix timestamp to sql server timestamp. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.