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

Kutools for Excel - Helps You To Stand Out From Crowd

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ...
Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup...
Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List...
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Description


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