Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: Understanding Date and Time Formatting Codes.

Understanding Date and Time Formatting Codes

by Allen Wyatt
(last updated October 6, 2017)

5

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. You can use one of Excel's pre-defined date and time formats or you can create your own custom format. Regardless of which approach you take, you use the Number tab of the Format Cells dialog box (display the Home tab of the ribbon, click the small icon at the bottom-right of the Number group, then make sure the Number tab is displayed.) The Date, Time, and Custom options all appear at the right of the dialog box. (See Figure 1.) If you create a custom format for your dates and times, you need to become conversant in the codes you can use to define those formats. 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 (display the Home tab of the ribbon, click the small icon at the bottom-right of the Number group, then choose Custom in the Category list).
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 (8319) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel 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

Canceling Printing

Need to stop the printing of a long document? Here's how to stop Word, along with why stopping Word may not be the only ...

Discover More

Viewing Formulas in Table Cells

Word allows you to insert simple formulas, using fields, in table cells. If you want to see these formulas in their ...

Discover More

Removing a Directory

Macros allow you to perform all sorts of file-related operations. One such operation allows you to delete a directory. ...

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 (ribbon)

Easy Value Hiding

Want a quick and easy way to hide the information in a cell? You can do it with a simple three-character custom format.

Discover More

Understanding Color and Conditional Formatting Codes

When you create custom cell formats, you can include codes that allow you to set the color of a cell and that specify the ...

Discover More

Altering the Displayed Format of Numbers to the Nearest 100

Want information in a worksheet to be formatted and displayed as rounded to a power of ten? You may be out of luck, ...

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}] 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 six more than 7?

2016-07-27 10:55:57

Olivia

Hi Allen,

I'm trying to format a date to read 27 JULY 2016. Right now I have been using the dd MMMM yyyy code to give me 27 July 2016. However, I cannot figure out which code will give me the month in full caps, JULY instead of July. Do you have any answer for this?

Thank you.


2015-08-19 15:21:52

Jake

I'm trying to add up a series of times in h:mm:ss format. I keep getting a total of 0:00:00 no matter how I format it. The formula I am using is SUM(C1:C###). There are a lot of rows, is the problem that I simply have too many values? We're talking about over 3,000 times. Thanks.


2014-04-09 19:21:26

Aldo

Don't forget one of my favs

*

Any character after the * is repeated to the width of the cell formatted.

Example:

Cell format: $*.0.0

Will display: $.......12.25


2014-04-09 07:03:41

Bryan

Andrew: hhmm"h"


2014-04-08 19:43:11

Andrew Thomas

Now, how do we format so the time shows up in the international 24-hour standard? That includes adding the 'h' at the end. To wit:

0135h or 1720h


This Site

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.

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.