Convert YYYYMMDD-HHMMSS Text to an Excel Date and Time
Question details
Convert a text string in YYYYMMDD-HHMMSS format into a usable spreadsheet date and time.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A cell contains a date followed by a time, such as 20180709-150633, and the user needs to combine the components into one date-time value.
- Observed behavior
- The desired result is a date-time value that can be formatted, sorted, and used in calculations.
Check that the source text has eight date digits, a hyphen, and six time digits, such as 20180709-150633. The example formula assumes the text is in cell B3.
Convert the text with Excel DATE and TIME functions
Use this formula to extract each component and create a date-time value in a separate cell.
Select an empty cell and enter =DATE(LEFT(B3,4),MID(B3,5,2),MID(B3,7,2))+TIME(MID(B3,10,2),MID(B3,12,2),MID(B3,14,2)). Replace B3 with the cell containing your text if needed.
Right-click the result cell, select Format Cells, and choose Custom. Enter yyyy-mm-dd hh:mm:ss as the format, then select OK.
Select the formula cell and drag its fill handle down alongside the remaining source values.

Convert date-time text in WPS Spreadsheets
Use the same DATE and TIME formula in WPS Spreadsheets, then apply a custom format to display the result as a readable date and time.
- 1. Open the spreadsheet: Open your workbook in WPS Spreadsheets and locate the cell containing the date-time text.
- 2. Enter the conversion formula: In an empty cell, enter =DATE(LEFT(B3,4),MID(B3,5,2),MID(B3,7,2))+TIME(MID(B3,10,2),MID(B3,12,2),MID(B3,14,2)), replacing B3 if your source is elsewhere.
- 3. Set the display format: Right-click the result cell, open Format Cells, and select Custom. Enter yyyy-mm-dd hh:mm:ss and confirm the format.
- 4. Fill down if needed: Drag the result cell's fill handle down to convert additional rows.

Frequently Asked Questions
Why does the formula result appear as a number?
Excel stores dates and times as serial numbers. Right-click the result, choose Format Cells, and apply the custom format yyyy-mm-dd hh:mm:ss.
Can I use the converted value in calculations?
Yes. The DATE and TIME formula produces a numeric date-time value that you can subtract, sort, or use in other formulas.
What if my source text is not in B3?
Replace every B3 reference in the formula with the cell containing your source text. When you fill the formula down, the relative references will adjust for each row.
Will the formula detect an invalid date or time?
Not always. DATE and TIME can roll out-of-range components into another date or time. Check that the source has valid date and time components before relying on the result.




