Excel Formula: Convert Datetime String to Datetime

doc calculate difference between time 5

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.
doc calculate difference between time 5

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.
doc calculate difference between time 5

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.
doc calculate difference between time 5

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.
doc calculate difference between time 5

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.
doc calculate difference between time 5doc calculate difference between time 5

Now the numbers have been changed to the datetime format.
doc calculate difference between time 5


Relative Formulas

Relative Functions


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

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, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.