How can I convert UNIX timestamp (bigint) to DateTime in SQL Server?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
This worked for me:
In case any one wonders why 1970-01-01, This is called Epoch time.
Below is a quote from Wikipedia:
The Year 2038 Problem
Furthermore the DataAdd function takes an
intfor the seconds to add. So if you are trying to add more than2147483647seconds 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.This will let you convert a timestamp that represents a year greater than 2038.