convert string "5/31/2016" to date format in excel like 2016-05-31
- User
convert string "5/31/2016" to date format in excel like 2016-05-31
- Assistant
To convert the string
"5/31/2016"in Excel to the date format2016-05-31, follow these steps:Method 1: Using
DATEVALUEandTEXTfunctions-
Suppose the string
"5/31/2016"is in cellA1. -
In another cell, enter the formula:
excel=TEXT(DATEVALUE(A1), "yyyy-mm-dd")
This formula does two things:
DATEVALUE(A1)converts the string to an Excel date serial number.TEXT(..., "yyyy-mm-dd")converts that date into the desired format as a text string.
Method 2: Change Cell Format (if Excel recognizes it as a date)
If Excel already understands your cell as a date (not just text), you can:
-
Right-click the cell and choose Format Cells.
-
Under the Number tab, select Custom.
-
Enter the format:
codeyyyy-mm-dd -
Click OK.
Notes:
- If Excel doesn't recognize the text as a date, the first method (
DATEVALUE) is recommended. - The result of the
TEXTformula is text, so if you need a real date value, keep the cell as a date and only change the format.
-
- User
Getting #Value
- Assistant
The
#VALUE!error usually means Excel is not able to interpret the text"5/31/2016"as a valid date forDATEVALUE. This can happen due to regional date settings or if the cell content is text and not a recognizable date.Step-by-step troubleshooting and fix:
1. Confirm the date string is exactly
"5/31/2016"in cellA1without extra spaces-
Sometimes extra spaces cause issues. Use this formula to trim spaces:
excel=TRIM(A1) -
Alternatively, re-type the date string in the cell to be sure.
-