Convert dates stored as text to dates

Occasionally, dates may become formatted and stored in cells as text. For example, you may have entered a date in a cell that was formatted as text, or the data might have been imported or pasted from an external data source as text.

Dates that are formatted as text are left-aligned instead of right-aligned in a cell. With Error Checking turned on, text dates with two-digit years might also be marked with an error indicator Cell with a formula problem.

Because Error Checking in Microsoft Office Excel can identify text-formatted dates with two-digit years, you can use the automatic correction options to convert them to date-formatted dates. You can use the DATEVALUE function to convert most other types of text dates to dates.

What do you want to do?


Convert text dates with two-digit years by using Error Checking

  1. Click the Microsoft Office Button Button image, and then click Excel Options.
  1. Click Formulas, and then do all of the following:
    1. Under Error Checking, make sure that the Enable background error checking check box is selected.
    2. Under Error checking rules, make sure that the Cells containing years represented as 2 digits check box is selected.
    3. Click OK.
  2. In the worksheet, select any cell or range of cells with an error indicator in the upper-left corner Cell with a formula problem.

 Note   The selected cells must be adjacent.

ShowHow 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 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. 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.

Worksheet showing row heading and column heading

Callout 1 Row heading
Callout 2 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 (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.

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

  1. Next to the selected cell or range of cells, click the error button Button image that appears, and then click either Convert XX to 20XX or Convert XX to 19XX.

Top of Page Top of Page

Convert text dates by using the DATEVALUE function

To convert a text date in a cell to a serial number, you use the DATEVALUE function. Then you copy the formula, select the cells that contain the text dates, and use Paste Special to apply a date format to them.

  1. Select a blank cell and verify that its number format is General.

ShowHow to verify the number format

  • On the Home tab, in the Number group, click the arrow next to the Number Format box, and then click General.

Excel Ribbon Image

  1. In the blank cell:
    1. Type =DATEVALUE(
    2. Click the cell that contains the text-formatted date that you want to convert.
    3. Type )
    4. Press ENTER.

The DATEVALUE function returns the serial number of the date that is represented by the text date.

ShowWhat is a serial number?

Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900, is serial number 1, and January 1, 2008, is serial number 39448 because it is 39,448 days after January 1, 1900.

  1. To copy the conversion formula into a range of contiguous cells, select the cell in which you typed the formula, and then drag the fill handle fill handle image across a range of empty cells that matches in size the range of cells that contain text dates.

After you drag the fill handle, you should have a range of cells with serial numbers that corresponds to the range of cells that contain text dates.

  1. Select the cell or range of cells that contains the serial numbers, and then on the Home tab, in the Clipboard group, click Copy.

Excel Ribbon Image

Keyboard shortcut  You can also press CTRL+C.

  1. Select the cell or range of cells that contains the text dates, and then on the Home tab, in the Clipboard group, click the arrow below Paste, and then click Paste Special.
  2. In the Paste Special dialog box, under Paste, select Values, and then click OK.
  3. On the Home tab, in the Number group, click the arrow next to the Number Format box, and then click Short Date or Long Date.

Excel Ribbon Image

 Tip   For other date formats, click More. In the Format Cells dialog box, on the Number tab, click Date in the Category box, and then click the date format that you want in the Type box.

  1. To delete the serial numbers after all of the dates are converted successfully, select the cells that contain them, and then press DELETE.

Top of Page Top of Page

 
 
Applies to:
Excel 2007