Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Converting UNIX Date/Time Stamps.
Written by Allen Wyatt (last updated April 14, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
When you import information created by other computer programs, you may run into a situation where your data includes a date/time stamp created by UNIX. Once imported, you are then faced with the challenge of converting the date/time stamp to an Excel date/time format. Doing the conversion is rather easy, once you understand how both systems save their time.
Time stamps in UNIX are stored as an integer value representing the number of seconds since 1 January 1970. Further, time stamps are stored in GMT time, meaning there has been no adjustment to the stamp to reflect time zones or time-zone variations (such as Daylight Savings Time).
Excel, on the other hand, stores time stamps as a real number representing the number of days since 1 January 1900 (the default setting). The integer portion of the time stamp represents the number of full days, while the portion of the time stamp to the right of the decimal point represents the fractional portion of a day, which can be converted to hours, minutes, and seconds.
To do a straight conversion of a UNIX time stamp to the Excel system, all you need to do is use this formula:
=UnixTime / 86400 + 25569
In this example, UnixTime can be either a named cell containing the integer UNIX time stamp value, or it can be replaced with the actual integer value. Since the UNIX time stamp is stored as seconds, the division by 86400 is necessary to convert to days, which is used by Excel. (86400 is the number of seconds in a day.) You then add 25569, which is the number of days between 1 January 1900 and 1 January 1970. (It is the value returned if you use the =DATE(1970,1,1) function.)
Remember, that this does a straight conversion. You may still need to adjust for time zones. If the UNIX system recorded something occurring at 5:00 pm local time, you need to determine how many hours difference there is between you and GMT. If there happens to be four hours, then you need to adjust your conversion formula, accordingly, as shown here:
=UnixTime / 86400 + 25569 - 4 / 24
If you are unsure of how your time zone relates to GMT, you can find the needed information here:
http://tycho.usno.navy.mil/zones.html
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10849) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Converting UNIX Date/Time Stamps.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
When you load data into Excel that was created in other programs, the formatting used for some types of data (such as ...
Discover MoreExcel allows you to perform all sorts of calculations using dates. A good example of this is using a formula to figure ...
Discover MoreDifferent businesses have different ways to calculate elapsed time for billing purposes. Figuring out a formula that ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-04-14 09:56:06
Dave Bonin
Link to http://tycho.usno.navy.mil/zones.html does not work.
2023-04-14 06:58:29
Mark
To actually do this conversion I'd heavily consider using Power Query. I say this because I'm assuming (yes, I know, dangerous to do so) that once the date/time is actually converted these steps would likely be taken:
- the new column would have a copy/paste special/value done,
- followed by deleting the original column,
- possibly the new column be formatted to show date/time,
- and then I guess various other column title renames,
- position rearrangements,
- maybe filters, etc.
If the file would need regular imports building the Power Query would very quickly pay dividends.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments