How to convert YYYYMMDD to a date in Excel
Formula (Excel and Google Sheets)
=DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2))Cut out the year, month and day and rebuild the date: =DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2)).
- Result on the example
- one result per row in
B2, filled down toB6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in B2, filled down to B6. Change any input and the result updates, or edit the formula to experiment.
How it works
LEFT, MID and RIGHT cut the year, month and day out of the eight digits, and DATE puts them together as a real date. They work on numbers too, because the text functions turn the number into text first.
=DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2))Result3/5/2026 (46086)
A220260305The value in A2.
LEFT(A2,4)"2026"LEFT: Characters from the start of text.- text
A220260305 - num_chars
4
- text
MID(A2,5,2)"03"MID: Characters from the middle of text.- text
A220260305 - start_num
5 - num_chars
2
- text
RIGHT(A2,2)"05"RIGHT: Characters from the end of text.- text
A220260305 - num_chars
2
- text
DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2))3/5/2026 (46086)DATE: Builds a date from parts.- year
LEFT(A2,4)"2026" - month
MID(A2,5,2)"03" - day
RIGHT(A2,2)"05"
- year
In Google Sheets
The same formula works in Google Sheets: =DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2)). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =DATE(INT(A2/10000),MOD(INT(A2/100),100),MOD(A2,100)) | 3/5/2026, 12/31/2025, 1/10/2026… | Does the same with arithmetic instead of text functions. |
Common mistakes
- A date format on 20260305 doesn't work: it is read as day number 20,260,305, beyond the year 9999, and shows as ####.
- If the column has blanks, wrap it:
=IF(A2="","",DATE(…)), or the blank rows show #VALUE!. - DATE quietly rolls invalid dates forward: 20260231 becomes March 3, 2026. Check suspicious source values.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Convert YYYYMMDD to a date
B2, convert the eight-digit YYYYMMDD number in A2 to a real date, and fill down to B6.Questions
How do I convert the date back to YYYYMMDD?
=TEXT(B2,"yyyymmdd") gives text; wrap it in -- for a number.
What about DDMMYYYY numbers?
Pad them to 8 digits first, since a leading zero is lost: =DATE(RIGHT(A2,4),MID(TEXT(A2,"00000000"),3,2),LEFT(TEXT(A2,"00000000"),2)).
What if the value includes a time, like 202603140930?
Add the time from the last four digits: =DATE(LEFT(A2,4),MID(A2,5,2),MID(A2,7,2))+TIME(MID(A2,9,2),RIGHT(A2,2),0).
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.