Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Converting Mainframe Date Formats.

Converting Mainframe Date Formats

by Allen Wyatt
(last updated September 20, 2014)

2

Some of the data you work with in Excel may start as output from large systems in your office. Sometimes the date formats used by the large systems may be completely misunderstood by Excel. For instance, the output may provide dates in the format yyyydddtttt, where yyyy is the year, ddd is the ordinal day of the year (1 through 366), and tttt is the time based on a 24-hour clock. At first glance, you may not know how to convert such a date to something that Excel can use.

There are many ways that a solution could be approached. Perhaps the best formula, however, is the following:

=DATE(LEFT(A1,4),1,1)+MID(A1,5,3)-1+TIME(MID(A1,8,2),RIGHT(A1,2),0)

This formula first figures out the date serial number for January 1 of the specified year, then adds the correct number of days to that date. The formula then calculates the right time based on what is provided.

When a formula like this is invoked, the result is a date serial number. This means that the cell still needs to be formatted to display a date format.

This approach will work just fine, provided that the information that you start with makes sense. For instance, you will always get the expected result if ddd really is within the range of 1 through 366, or if tttt is a properly formatted 24-hour representation of time. If you anticipate original data that could be out of bounds, then the best solution is to create a custom function (using a macro) that will tear apart the original data and check the values provided for each portion. If the data is out of bounds, the function could return an error value that would be easily detected within the worksheet.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2524) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Converting Mainframe Date Formats.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Inserting a Sound File in Your Worksheet

Some worksheets are better understood through the spoken word or with musical accompaniment. Sound files can be easily ...

Discover More

Determining an Integer Value

One of the math functions you can use in your macros is the Int function. It provides a way for you to derive an integer ...

Discover More

Easy Filtering Specifications for a PivotTable

When you want to include specific records from a source table into a PivotTable, you need to employ some sort of filtering. ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

MORE EXCELTIPS (MENU)

Getting Rid of 8-Bit ASCII Characters

When working with data created outside of Excel, you may need to check that data to make sure it contains no unwanted ...

Discover More

Converting UNIX Date/Time Stamps

If you import information generated on a UNIX system, you may need to figure out how to change the date/time stamps to ...

Discover More

Pulling Apart Characters in a Long String

You can easily use formulas to pull apart text stored in a cell. For instance, if you need to pull individual characters from ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine more than 2?

2016-05-02 13:35:28

Greg Mouning

Jagdish,

I think you want to use the Excel TEXT function. Take a look at the following support weblink for options:

https://support.office.com/en-US/article/TEXT-function-20D5AC4D-7B94-49FD-BB38-93D29371225C

-----------------
Syntax

TEXT(value, format_text)

The TEXT function syntax has the following arguments:

value Required. A numeric value, a formula that evaluates to a numeric value, or a reference to a cell containing a numeric value.


format_text Required. A numeric format as a text string enclosed in quotation marks, for example "m/d/yyyy" or "#,##0.00". See the following sections for specific formatting guidelines.


2016-05-01 21:25:57

jagdish chander arya

i have change a zip file into excel and I want to change the date format as the date was like 3/15/2016 in zip file now i want to change it like 15-03-2016 in excel


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing
Share