Display numbers as dates or times
When a date or time is typed in a cell, it appears in a default date and time format. The default date and time format is based on the regional date and time settings that are specified in Windows Control Panel, and changes when changes are made to those settings. You can display numbers in several other date and time formats, most of which are not affected by Control Panel settings.
- Select the cells that you want to format.
How to select cells, ranges, rows, or columns
To select Do this A single cell Click the cell, or press the arrow keys to move to the cell. A range of cells Click the first cell in the range, and then drag to the last cell, or hold down SHIFT while you press the arrow keys to extend the selection. You can also select the first cell in the range, and then press F8 to extend the selection by using the arrow keys. To stop extending the selection, press F8 again.
A large range of cells Click the first cell in the range, and then hold down SHIFT while you click the last cell in the range. You can scroll to make the last cell visible. All cells on a worksheet Click the Select Allbutton.
To select the entire worksheet, you can also press CTRL+A.
Note If the worksheet contains data, CTRL+A selects the current region. Pressing CTRL+A a second time selects the entire worksheet.
Nonadjacent cells or cell ranges Select the first cell or range of cells, and then hold down CTRL while you select the other cells or ranges. You can also select the first cell or range of cells, and then press SHIFT+F8 to add another nonadjacent cell or range to the selection. To stop adding cells or ranges to the selection, press SHIFT+F8 again.
Note You cannot cancel the selection of a cell or range of cells in a nonadjacent selection without canceling the entire selection.
An entire row or column Click the row or column heading.
Row heading
Column heading
You can also select cells in a row or column by selecting the first cell and then pressing CTRL+SHIFT+ARROW key (RIGHT ARROW or LEFT ARROW for rows, UP ARROW or DOWN ARROW for columns).
Note If the row or column contains data, CTRL+SHIFT+ARROW key selects the row or column to the last used cell. Pressing CTRL+SHIFT+ARROW key a second time selects the entire row or column.
Adjacent rows or columns Drag across the row or column headings. Or select the first row or column; then hold down SHIFT while you select the last row or column. Nonadjacent rows or columns Click the column or row heading of the first row or column in your selection; then hold down CTRL while you click the column or row headings of other rows or columns that you want to add to the selection. The first or last cell in a row or column Select a cell in the row or column, and then press CTRL+ARROW key (RIGHT ARROW or LEFT ARROW for rows, UP ARROW or DOWN ARROW for columns). The first or last cell on a worksheet or in a Microsoft Office Excel table Press CTRL+HOME to select the first cell on the worksheet or in an Excel list. Press CTRL+END to select the last cell on the worksheet or in an Excel list that contains data or formatting.
Cells to the last used cell on the worksheet (lower-right corner) Select the first cell, and then press CTRL+SHIFT+END to extend the selection of cells to the last used cell on the worksheet (lower-right corner). Cells to the beginning of the worksheet Select the first cell, and then press CTRL+SHIFT+HOME to extend the selection of cells to the beginning of the worksheet. More or fewer cells than the active selection Hold down SHIFT while you click the last cell that you want to include in the new selection. The rectangular range between the active cell and the cell that you click becomes the new selection. Tip To cancel a selection of cells, click any cell on the worksheet.
- On the
Hometab, click theDialog Box Launcher
next to Number.
- In the
Categorylist, clickDateorTime. - In the
Typelist, click the date or time format that you want to use.Note Date and time formats that begin with an asterisk (*) respond to changes in regional date and time settings that are specified in Windows Control Panel. Formats without an asterisk are not affected by Control Panel settings.
Dates or times that you type into formatted cells will be displayed in the format that you selected.
- To display dates and times in the format of other languages, click the language setting that you want in the
Locale (location)box.
Tips
- The number in the active cell of the selection on the worksheet appears in the
Samplebox, so that you can preview the number formatting options that you select. - To quickly format a date or time, click the date or time format that you want in the
Number Formatbox in theNumbergroup on theHometab. - If you don't find the format that you are looking for in the
Typelist, you can create a custom number format by clickingCustomin theCategorylist, and then by using format codes for dates and times.Learn about custom date and time codes
Days, months, and years If you use "m" immediately after the "h" or "hh" code or immediately before the "ss" code, Microsoft Office Excel displays minutes instead of the month.
To display Use this code Months as 1-12 m Months as 01-12 mm Months as Jan-Dec mmm Months as January-December mmmm Months as the first letter of the month mmmmm Days as 1-31 d Days as 01-31 dd Days as Sun-Sat ddd Days as Sunday-Saturday dddd Years as 00-99 yy Years as 1900-9999 yyyy
Hours, minutes, and secondsTo display Use this code Hours as 0-23 H Hours as 00-23 hh Minutes as 0-59 m Minutes as 00-59 mm Seconds as 0-59 s Seconds as 00-59 ss Hours as 4 AM h AM/PM Time as 4:36 PM h:mm AM/PM Time as 4:36:03 P h:mm:ss A/P Elapsed time in hours; for example, 25.02 [h]:mm Elapsed time in minutes; for example, 63:46 [mm]:ss Elapsed time in seconds [ss] Fractions of a second h:mm:ss.00
AM and PM If the format contains an AM or PM, the hour is based on the 12-hour clock, where "AM" or "A" indicates times from midnight until noon and "PM" or "P" indicates times from noon until midnight. Otherwise, the hour is based on the 24-hour clock. The "m" or "mm" code must appear immediately after the "h" or "hh" code or immediately before the "ss" code; otherwise, Microsoft Office Excel displays the month instead of minutes. - If you want to use the default date or time format, click the cell that contains the date or time, and then press CTRL+SHIFT+# or CTRL+SHIFT+@.
Notes:
- A cell may display ##### when it contains data that has a number format that is wider than the column width. To see all text, you must increase the width of the column.
How to change the column width
- Click the cell for which you want to change the column width.
- On the
Hometab, in theCellsgroup, clickFormat.
- Under
Cell Size, do one of the following:- To fit all text in the cell, click
AutoFit Column Width. - To specify a larger column width, click
Column Width, and then type the width that you want in theColumn widthbox.
- To fit all text in the cell, click
- When you try to undo a date or time format by selecting
Generalin theCategorylist, Excel displays a number code. When you enter a date or time again, Excel displays the default date or time format. To enter a specific date or time format, such asJanuary 2005, you may want to format it as text by selectingTextin theCategorylist.
See also:
- Change the default country/region
- Display numbers as currency
- Display numbers as fractions
- Display numbers as percentages