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: Understanding Date and Time Formatting Codes.

Understanding Date and Time Formatting Codes

Written by Allen Wyatt (last updated November 27, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003


In Excel, dates and times are stored internally as numbers. These are only converted to legible dates and times when you format the cell using a date or time format. The following table lists the formatting codes that are specific to dates and times. You use these codes when you are creating a custom display format (Format | Cells | Number tab | Custom).

Symbol Meaning
m Displays the month or minutes as a number without a leading 0
mm Displays the month or minutes as a number with a leading 0
mmm Displays the month as abbreviated text (Jan, Feb, Mar, and so on)
mmmm Displays the month as text (January, February, March, and so on)
d Displays the day of the month as a number without a leading 0
dd Displays the day of the month as a number with a leading 0
ddd Displays the day of the week as abbreviated text (Sun, Mon, Tue, and so on)
dddd Displays the day of the week as text (Sunday, Monday, Tuesday, and so on)
yy Displays the year with two digits
yyyy Displays the year with four digits
h Displays the hour without a leading 0
hh Displays the hour with a leading 0
s Displays the seconds without a leading 0
ss Displays the seconds with a leading 0
[ ] When surrounding hours, minutes, or seconds place holders, displays hours greater than 24 or minutes and seconds greater than 60
AM am PM pm A a P p Uses a 12-hour clock, displaying AM or PM as specified
\ Forces display of the following character
. (period) The decimal point.
"text" Displays the text within the quotes.

To understand better the effect of the date and time codes, take a look at the following information, which shows several common date and time formats and how they affect numbers.

Category Format Value Displayed As
Date m/d/yy 34369 2/4/94
 d-mmm-yy 34409 16-Mar-94
Time h:mm AM/PM 0.654166667 3:42 PM
 [h]:mm:ss 2.592673611 62:13:27

Notice that the numbers shown in the value column of these examples are the internal values stored by Excel for dates and times.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2179) 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: Understanding Date and Time Formatting Codes.

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

Running Macros on Hidden Worksheets

Excel allows you to hide worksheets so that they aren't visible to those using your workbook. Hiding worksheets has a ...

Discover More

Hyphenating Your Document

One of the final touches you can add to a document is to hyphenate it. This allows text to flow more smoothly from line ...

Discover More

Selectively Changing Endnotes to Footnotes

Want to turn some (but not all) of your endnotes into footnotes. Rather than do it manually, you can apply the shortcut ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Converting From Numbers to Text

If you have a range of numeric values in your worksheet, you may want to change them from numbers to text values. Here's ...

Discover More

Replacing Cell Formats

Need to replace the formats applied to some cells with a different format? Those using Excel 2003 will find it easy; ...

Discover More

Changing Font Size Using a Shortcut Key

Want to adjust the font size used in a cell or range of cells? It's easy to do by using the shortcut described in this tip.

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

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}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. 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 four minus 0?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

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.