Skip to main content

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


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.
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations