Data Cleaning: YYYYMMDD Text To A Real Date

Excel Formulas › Data Cleaning

All versions

Many systems export dates as eight digits, such as 20261025, which Excel treats as a plain number or text. It cannot sort by date or calculate days between. Slicing out the year, month and day and rebuilding them with DATE produces a real Excel date.


Quick formula: Take the first four characters as the year, the next two as the month and the last two as the day:
=DATE(LEFT(B2,4),MID(B2,5,2),RIGHT(B2,2))

20261025 becomes Sunday 10/25/2026, which falls in Q4.

Functions used (tap for the full reference guide):

The example

Three imported invoice dates. The second column shows the real date; the third shows its quarter.

ABCD
1CaseYYYYMMDDReal dateQuarter
2Invoice 120261025Sun 10/25/2026Q4
3Invoice 220260314Sat 3/14/2026Q1
4Invoice 320250731Thu 7/31/2025Q3

The formula

DATE needs three numbers; LEFT, MID and RIGHT supply them from the text:

=DATE(LEFT(B2,4),MID(B2,5,2),RIGHT(B2,2)) // real date; quarter = "Q"&ROUNDUP(MONTH(date)/3,0)

How it works

Here is the logic, one piece at a time:

  1. LEFT(B2,4) is the year.
  2. MID(B2,5,2) is the month, starting at character 5.
  3. RIGHT(B2,2) is the day.
  4. DATE(...) builds a true Excel date from the three parts.

Format the result column as a date; the underlying value is a serial number.

Try it: interactive demo

Interactive

Type an 8-digit date such as 20261025.

Variations

Handle numbers and text

Works if the source is a true number.

=DATE(INT(B2/10000),MOD(INT(B2/100),100),MOD(B2,100))

Trap bad dates

Return a blank instead of an error.

=IFERROR(DATE(LEFT(B2,4),MID(B2,5,2),RIGHT(B2,2)),"")

Pitfalls & errors

If a date is not exactly 8 characters, MID and RIGHT slice the wrong characters. Check with LEN(B2)=8 first.

Excel silently rolls over invalid dates such as month 13. Validate the parts if your source is unreliable.

Store the result as a date and format it as you like; do not convert it back to text.

Practice workbook

📊
Download the free Data Cleaning: YYYYMMDD Text To A Real Date practice workbook
Edit the yellow date-text cells; the real date and quarter recalculate.

Frequently asked questions

Why not use DATEVALUE?
DATEVALUE depends on regional settings and does not read 8-digit strings reliably.
Does this work for yyyymmdd numbers?
Yes, since LEFT, MID and RIGHT convert numbers to text, but the integer version is more explicit.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Data Cleaning: Standardize ZIP Codes To Five Digits · Data Cleaning: Strip A Trailing Comma, Period Or Semicolon · Build a Normalized Match Key

Function references: DATELEFTMIDRIGHT