Posts

Showing posts from November, 2020

Unix Timestamp or Epoch Timestamp to Datetime in SQL Server

Today I was working on extracting files from Amazon S3 to Azure Blob storage and I need to to refer to a control file to determine the start and end time of my extract. But unfortunately the timestamp in the control file was in Unix format.  Select lastSuccessfulWriteTimestamp from from ETL_CONTROL_TABLE ------------------------ 1590796601336 ------------------------ Now i need to convert this Unix Timestamp or Epoch to Datetime format so that my extract job can understand the the actual start date and end date. Now before proceeding let me explain what's a Unix Timestamp or Epoch Timestamp? Unix Timestamp or Epoch Timestamp is the number of  "seconds" from 1st January 1970 00:00:00 hrs. So a datetime  where  Date : 1st January 1970  Time : 03 : 00 : 00 am  will be represented in Unix Timestamp or Epoch Timestamp as   3 (hours) * 60 (min) *  60 (sec) = 10,800  (this is timestamp in seconds) 3 (hours) * 60 (min) *...