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. In addition, if Error Checking is 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 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-formatted dates to dates.

What do you want to do?


Convert text dates by using Error Checking

If you import data into Excel from another source, or if you type dates with two-digit years into cells that were previously formatted as text, you may see a small green triangle in the upper-left corner of the cell. This error indicator tells you that the date is stored as text, as shown in this example.

Cells with green error indicator in upper-left corner

Use the following procedure to convert the text-formatted date back to a regular date.

  1. On the worksheet, select any single cell or range of adjacent cells that has an error indicator in the upper-left corner.

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 that appears.

Error button

  1. On the menu, click either Convert XX to 20XX or Convert XX to 19XX. (If you want to simply get rid of the error indicator without converting the number, click Ignore Error.)

Commands for converting dates

This action converts the text dates with two-digit years to standard dates with four-digit years.

Converted dates

Once you have converted the cells from text-formatted dates, you can change the way the dates appear in the cells by applying date formatting. For more information, see Display numbers as dates or times.

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

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

Office 14 Ribbon

  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.

Office 14 Ribbon

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, click the Dialog Box Launcher next to Number.

Ribbon Image

  1. In the Category box, click Date, and then click the date format that you want in the Type list.
  2. 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

Turn off Error Checking

With error checking turned on in Excel, you see an error indicator if you enter a date with a two-digit year into a cell that has text formatting applied to it. If you want, you can turn off this Error Checking feature.

  1. Click the File tab.
  2. Click Options.
  3. In the Excel Options dialog box, click the Formulas category.
  4. Under Error checking rules, clear the Cells containing years represented as 2 digits check box.
  5. Click OK.

Top of Page Top of Page

 
 
Applies to:
Excel 2010