Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Display numbers as dates or times
 
  1. Select the cell or range (range: Two or more cells on a sheet. The cells in a range can be adjacent or nonadjacent.) or cells that you want to format.

    ShowHow to select a cell or a range

    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 of 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 of the range and then press F8 to extend the selection by using the arrow keys.

    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 All button.

    Select All button

    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.

    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.

    Worksheet showing row heading and column heading

    Callout 1 Row heading 

    Callout 2Column 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.
    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 (active cell: The selected cell in which data is entered when you begin typing. Only one cell is active at a time. The active cell is bounded by a heavy border.) and the cell that you click becomes the new selection.

    Note  To cancel a selection of cells, click any cell on the worksheet.

  2. On the Format menu, click Cells.
  3. On the Number tab, in the Category list, click Date or Time.
  4. In the Type list, click the format that you want to use.

    Dates or times that you type into formatted cells will be displayed in the format that you selected.

Notes

  • A cell may display ##### when it contains data that has a number format that is wider than the column width. To increase the width of the column, select it, point to Column on the Format menu, and then click AutoFit Selection.
  • When a date or time is typed in a cell, it appears either in a default date or time format or in a format that was applied to the cell before the date or time was typed. (The default date or time format is based on settings in the regional settings in Control Panel.) If the default date settings are changed, any existing dates or times in your workbooks that are not formatted with the Format Cells command also change.
  • 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+@.
  • If you don't find the format you're looking for in the Type list, you can create a custom number format by using format codes for dates and times. For more information, click Create or delete a custom number format, or explore the following custom date and time codes.

    ShowCustom 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 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 seconds
    To 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 Excel displays the month instead of minutes.
  • When you try to undo a date or time format by selecting General in the Category list, 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 as January 2005, you may want to format it as text by selecting Text in the Category list.
© 2009 Microsoft Corporation. All rights reserved.