Data Import & Export

Convert YYYYMMDD-HHMMSS Text to an Excel Date and Time

Phi Hung VoPhi Hung Vo Nov 18, 2026 868 views

Question details

Convert a text string in YYYYMMDD-HHMMSS format into a usable spreadsheet date and time.

Convert YYYYMMDD-HHMMSS Text to an Excel 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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the formula

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.

2
Format the result

Right-click the result cell, select Format Cells, and choose Custom. Enter yyyy-mm-dd hh:mm:ss as the format, then select OK.

3
Apply it to other rows

Select the formula cell and drag its fill handle down alongside the remaining source values.

Convert the text with Excel DATE and TIME functions
Check the result: For 20180709-150633, the formatted result should be 2018-07-09 15:06:33. DATE and TIME can roll out-of-range components into another date or time, so check that source values are valid.
Convert dates in WPS Spreadsheets

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. 1. Open the spreadsheet: Open your workbook in WPS Spreadsheets and locate the cell containing the date-time text.
  2. 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. 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. 4. Fill down if needed: Drag the result cell's fill handle down to convert additional rows.
Convert compact date-time text into values usable in calculationsOpen and edit Microsoft Excel XLSX filesApply the formula to multiple rows with the fill handleUse familiar spreadsheet formulas and formatting tools
microsoft office alternative - wps office

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.