Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Convert Number String to Date

· 4 min read · Home Tech

In this article
  1. Why Excel Shows Numbers Instead of Dates
  2. Formula to Convert YYYYMMDD to Date
  3. Converting a Serial Number to a Date
  4. How to Convert Text to Date Using Text to Columns
  5. Common Mistakes and Fixes
  6. Handling Different Date Formats
  7. Frequently Asked Questions

This article explains how to convert a number string (like 20240315 or 45000) into a real date in Excel. You’ll learn the formulas, the pitfalls, and the step-by-step process to get a proper date format instead of a text string.

Why Excel Shows Numbers Instead of Dates

Excel stores dates as serial numbers—the number of days since January 1, 1900 (or 1904 on Mac). When you type a date like 03/15/2024, Excel converts it to the serial number 45366 and then displays it using a date format. But when you import data from another system, a CSV file, or a database, you often get a number string such as “20240315” or “45000” that Excel treats as plain text or a plain number, not a date. That’s why you need to convert it.

Formula to Convert YYYYMMDD to Date

If your number string is in the format YYYYMMDD (e.g., 20240315), use the DATE function:

=DATE(LEFT(A1,4), MID(A1,5,2), RIGHT(A1,2))

Here’s how it works:

  • LEFT(A1,4) extracts the year (2024).
  • MID(A1,5,2) extracts the month (03).
  • RIGHT(A1,2) extracts the day (15).

The DATE function returns a real Excel date, which you can then format as you like. If your string is in MMDDYYYY or DDMMYYYY order, just adjust the positions accordingly.

Converting a Serial Number to a Date

If you have a plain number that is already an Excel serial date (like 45000), you don’t need a formula—just change the cell format to Date. Select the cell, press Ctrl+1 (or Cmd+1 on Mac), go to the Number tab, choose Date, and pick a format. If the number is in a text string, you can convert it to a number first by multiplying by 1 or using the VALUE function, then apply the date format.

How to Convert Text to Date Using Text to Columns

For a column of number strings, the Text to Columns wizard is a quick fix:

  1. Select the column with the number strings.
  2. Go to Data > Text to Columns.
  3. Choose “Delimited” and click Next.
  4. Uncheck all delimiters and click Next.
  5. Under “Column data format,” select “Date” and choose the order that matches your string (e.g., YMD if it’s 20240315).
  6. Click Finish.

This works for YYYYMMDD, MMDDYYYY, and similar fixed-length strings.

Common Mistakes and Fixes

One common mistake is using the DATEVALUE function on a number string—it only works on text that looks like a date (e.g., “3/15/2024”), not on “20240315”. Another issue is that after using the DATE formula, you might see a serial number instead of a date—that just means the cell format is General. Apply a date format to fix it.

If your string has slashes or dashes, like “2024-03-15”, you can use DATEVALUE directly, but be aware that Excel may interpret it differently depending on your regional settings. For a string like “15-03-2024”, use DATEVALUE with the correct order, or use the DATE function with MID and RIGHT as shown earlier.

Handling Different Date Formats

Not all number strings are YYYYMMDD. Here are common variations and how to handle them:

  • MMDDYYYY (e.g., 03152024): Use =DATE(RIGHT(A1,4), LEFT(A1,2), MID(A1,3,2)).
  • DDMMYYYY (e.g., 15032024): Use =DATE(RIGHT(A1,4), MID(A1,3,2), LEFT(A1,2)).
  • YYYYDDMM (rare): Use =DATE(LEFT(A1,4), RIGHT(A1,2), MID(A1,5,2)).

Always verify the order by checking a known date in your data.

Frequently Asked Questions

Why does my DATE formula return a number like 45366?

That’s because the cell is formatted as General or Number. The DATE function returns a serial number; you need to apply a date format to the cell to see it as a date. Select the cell, press Ctrl+1, choose Date, and pick a format.

Can I convert a number string to a date without a formula?

Yes, use Text to Columns as described above. It’s the fastest way for a column of data. Alternatively, you can use Find & Replace to add slashes, but that’s more error-prone.

What if my number string has leading zeros, like 00152024?

Excel may drop leading zeros when you type them, but if the cell is formatted as Text, they stay. The DATE formula will still work because LEFT and MID treat the cell content as text, so leading zeros are preserved.

How do I convert a text date like “2024-03-15” to a real date?

Use DATEVALUE, but first replace the dashes with slashes: =DATEVALUE(SUBSTITUTE(A1,"-","/")). This works in most regional settings. If that fails, use the DATE function with MID and LEFT as shown earlier.

Why does my imported CSV show dates as text with a green triangle?

The green triangle indicates the cell is text. Select the column, click the warning icon, and choose “Convert to Number.” Then apply a date format. If that doesn’t work, use Text to Columns with the Date option.

Can I convert a Unix timestamp to a date in Excel?

Yes, if the timestamp is in seconds, use =A1/86400 + DATE(1970,1,1). If it’s in milliseconds, divide by 86400000 first. Then format the result as a date.