Excel Formula: Convert Datetime String to Datetime
Sometimes, while you import or paste some datetime data from other devices to Excel, the datetimes maybe not be recognized as proper dates. In this case, the Excel will store the datetime data as texts. Here in this tutorial, it introduces the formulas to quickly convert the date string to datetime.
If you want to follow along with this tutorial, please download the example spreadsheet.
Convert datetime string to date only
Generic formula:
LEFT(date,10) |
Arguments
Date: the date string that you want to convert to date. |
Return Value
This formula returns value in date format.
How this formula work
Supposing in cell B3:B5 there is a list of datetime strings, to extract the date from the datetime strings in cell C3, please use below formula:
=LEFT(B3,10) |
Press Enter key, the drag auto fill handle from cell C3 to cell C5.
Explanation
The Left function is used to extract a specific number of characters from left side of a string. Here extracts the first 10 characters from the datetime string.
Convert datetime string to time only
Generic formula:
MID(date,12,8) |
Arguments
Date: the date string that you want to convert to date. |
Return Value
This formula returns value in time format.
How this formula work
Supposing in cell B3:B5 there is a list of datetime strings, to extract the time from the datetime strings in cell D3, please use below formula:
=MID(B3,12,8) |
Press Enter key, , the drag auto fill handle from cell D3 to cell D5.
Explanation
The MID function is used to find and return a specific number of characters from the middle of given text string. Here the time string is in the 12th position of the string, and the length is 8-chars.
Convert datetime string to datetime
Before getting the datetime from the datetime string, you need to get the date and time separately firstly as above formulas do, then combine the date and time.
Supposing in cell B3:B5 there is a list of datetime strings, and you have extracted the date and time separately in cells C3:C5 and cells D3:D5, please use the formula as below to combine the date and time in cell E3:
=C3+D3
Press Enter key, the drag auto fill handle from cell D3 to cell D5.
The formula returns decimal numbers, now select these numbers, right click to select Format Cells from the context menu, then in the popping Format Cells dialog, choose Custom in the Category pane, then type m/d/yyyy h:mm:ss into the textbox of Type in right section. Click OK.
Now the numbers have been changed to the datetime format.
Relative Formulas
- Calculate Difference Between Two Dates
Here in this tutorial, it introduces the formulas on calculating difference between two dates in years, months, weeks, and days. - Calculate Calculate Days Hours Minutes Seconds Between Two Dates
Sometimes, we may want to get the days, hours, minutes, and seconds between two datetimes, this tutorial introduces the formula to solve this job. - Calculate Days Remaining Between Two Dates
Here, this tutorial provides a formula to quickly calculate the left days between two dates. - Calculate Hours Minutes Seconds Between Two Times
Here in this tutorial, it introduces some formulas to quickly present the time difference result as single time unit.
Relative Functions
- Excel IF Function
Test for specified conditions, then returns the corresponding values - Excel VALUE Function
Convert text to number. - Excel MONTH Function
The MONTH is used to get the month as integer number (1 to 12) from date. - Excel DAY Function
DAY function gets the day as a number (1 to 31) from a date - Excel YEAR Function
The YEAR function returns the year based on the given date in a 4-digit serial number format.
The Best Office Productivity Tools
Kutools for Excel - Helps You To Stand Out From Crowd
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
