Welcome to Sign in | Join | Help
in
Home Blog Forums

The Lazy Admin

Convert UNIX EPOCH Time Values into Excel/Windows time formats

Sponsor


During our migration we had a lot of issues with date formats. The old system didn't save its date as a type and as such caused us all sorts of trouble. The key to getting the dates working was to apply a cryptic yet simple formula to the date values in Excel.

The original Date Format was stored in Unix Epoch time. This is calculated as the number of seconds elapsed from 01/01/1970. Excel calculates the dates as the number of days from 01/01/1900.

The date value stored in the old database looked like this:

1171862018

1171807304

1158543880

In order to convert we apply some basic math. First we convert the seconds into days:

Divide 1171862018 by 86400 this will give you:

13563.2178 Or the number of days since 01/01/1970. Now of course were missing 70 years of days to make this date right. So we add 25569 to get a total of:

39132.2178.

Now just plug that value into an Excel cell and format as a date and you'll get 2/19/2007

Here is a look at the data as it goes through each step in the process:

Epoch Time To Days Added Days Converted to Time Format
1171862018 13563.2178 39132.2178 2/19/2007





Published Friday, April 20, 2007 8:35 AM by daniel.nerenberg
Filed under: ,

Comments

No Comments
Anonymous comments are disabled

About daniel.nerenberg

I am an MCT, Consultant based out of Montreal Quebec Canada. As the "new" Lazy Admin on the block I am working to make TheLazyAdmin.com the best website for MS Software tips and tricks out there!

This Blog

Powered By

 

Syndication

Sponsors

 
 
Get a free 5GB e-mail account @isalazyadmin.com

Certifications & Awards




All postings are provided "AS IS" with no warranties, and confer no rights.
Microsoft product screen shot(s) reprinted with permission from Microsoft Corporation.