KutoolsforOffice — One Suite. Five Tools. Get More Done.February Sale: 20% Off

How to convert yyyymmddhhmmss date format to normal datetime in Excel?

AuthorXiaoyangLast modified

In practice, it is common to encounter data exported from other systems or log files that present date and time as a single continuous string in yyyymmddhhmmss format. For example, “20240630174521” represents the date and time as 30/06/202417:45:21. However, Excel does not automatically recognize this string as a standard date-time value, which can make it challenging to analyze, sort, or perform calculations with these dates. Converting such strings to Excel’s recognizable datetime format (e.g., dd/mm/yyyy hh:mm:ss) is essential for further data analysis, filtering, or reporting.

This article provides practical step-by-step instructions to transform yyyymmddhhmmss strings into the standard Excel datetime format. We’ll cover multiple approaches, from using formulas for quick in-cell conversion, to automated VBA code solutions, as well as leveraging Excel’s Power Query for a more flexible, visual method. Each approach is suitable for different scenarios depending on your needs, data scale, and familiarity with Excel features.

convert yyyymmddhhmmss to normal datetime

Convert yyyymmddhhmmss to normal date time format with formulas

VBA Code - Convert yyyymmddhhmmss to normal date time automatically


Convert yyyymmddhhmmss to normal date time format with formulas

Excel formulas provide a quick, reliable way to split and reformat the yyyymmddhhmmss string into an Excel-recognized datetime value directly in your worksheet, without needing external add-ins or advanced tools. This approach is best suited for relatively small datasets or when you want a manual, transparent, and easily auditable transformation.

To convert the string, enter the following formula in a blank cell (for instance, in cell B2 if your original yyyymmddhhmmss value is in cell A2):

=TEXT(DATE(LEFT(A2,4),MID(A2,5,2),MID(A2,7,2))+TIME(MID(A2,9,2),MID(A2,11,2),MID(A2,13,2)),"dd/mm/yyyy hh:mm:ss")

Instructions: After entering the formula, press Enter to confirm. If you have a list of yyyymmddhhmmss values in column A, you can drag the fill handle from cell B2 down to quickly apply the formula to other rows. Each formula result gives you the formatted datetime as text.

This method is highly practical for ad-hoc data clean-up, small lists, or situations where you want to keep the original string intact in one column and the formatted value in another. Potential disadvantages: the formula result is still text; if you need Excel’s true datetime value for calculation (such as time differences), you might need to convert the text to a number format.

enter a formula to convert yyyymmddhhmmss to normal date time

Parameter explanations and tips:

  • LEFT(A2,4): extracts the 4-digit year
  • MID(A2,5,2): extracts the 2-digit month
  • MID(A2,7,2): extracts the 2-digit day
  • MID(A2,9,2): extracts the 2-digit hour
  • MID(A2,11,2): extracts the 2-digit minute
  • MID(A2,13,2): extracts the 2-digit second
  • The TEXT() function formats the result as a user-friendly date-time string.

Possible issues: If any of the original values are not exactly 14 digits (for example, missing leading zeros or accidentally entered as numbers in scientific notation), formulas may return incorrect results or errors. Double-check input consistency before using formula-based transformation.

Alternatively, if your data are always exactly 14 digits, this shorter formula converts the string and returns an Excel serial datetime value (not text):

=--TEXT(A2,"0000\-00\-00\ 00\:00\:00")

How to use: After entering this formula in a cell (such as B2), press Enter. Then, you may need to format the resulting cell(s) as DD/MM/YYYY HH:MM:SS using the Format Cells dialog box to display the value in human-readable date-time format. To do so, select the result cells, right-click, choose Format Cells > Custom, and enter dd/mm/yyyy hh:mm:ss as the format code.

use TEXT function

This second method is especially efficient if you want a real date value instead of a text string.

format the cell values to normal date time format in the Format Cells dialog box

Tip: If you intend to use the converted datetime results in further date math calculations (e.g., subtracting dates, finding durations), always use the formula that returns a serial number (the second formula), and then format it as needed.

Troubleshooting: If you get errors, check if your source data are true text and contain no non-numeric characters. Leading or trailing spaces may also affect results; consider cleaning data by using TRIM(A2) within the formula if you suspect this problem.


VBA Code - Convert yyyymmddhhmmss to normal date time automatically

For users who need to handle large datasets or wish to automate the conversion process, VBA (Visual Basic for Applications) provides a flexible solution. By looping through selected cells, you can convert each yyyymmddhhmmss value into a standard Excel datetime value in-place or in a target column. This approach is very useful when you want to avoid writing formulas across multiple cells or when your data updates frequently.

This method is suitable for larger datasets or recurring needs. However, using VBA requires enabling macros, which may be restricted by your organizational policies or Excel settings. Before running any VBA code, remember to save your file, as changes are not always easily reversed.

Operation steps:

  • Select the range of yyyymmddhhmmss values in your worksheet that you need to convert (e.g., A2:A100).
  • Click Developer tab > Visual Basic to open the VBA editor. In the left-hand pane, find your workbook, right-click, select Insert > Module. In the code window, paste the following code:
Sub Convert_yyyymmddhhmmss_To_DateTime()
    Dim rng As Range
    Dim cell As Range
    Dim strDate As String
    Dim y As Integer
    Dim m As Integer
    Dim d As Integer
    Dim hh As Integer
    Dim mm As Integer
    Dim ss As Integer
    
    On Error Resume Next
    xTitleId = "KutoolsforExcel"
    Set rng = Application.InputBox("Select the range of yyyymmddhhmmss values to convert:", xTitleId, Selection.Address, Type:=8)
    
    For Each cell In rng
        strDate = Trim(cell.Value)
        
        If Len(strDate) = 14 And IsNumeric(strDate) Then
            y = CInt(Left(strDate, 4))
            m = CInt(Mid(strDate, 5, 2))
            d = CInt(Mid(strDate, 7, 2))
            hh = CInt(Mid(strDate, 9, 2))
            mm = CInt(Mid(strDate, 11, 2))
            ss = CInt(Mid(strDate, 13, 2))
            
            cell.Value = DateSerial(y, m, d) + TimeSerial(hh, mm, ss)
            cell.NumberFormat = "dd/mm/yyyy hh:mm:ss"
        End If
    Next cell
End Sub

After pasting the code, close the VBA editor. Return to Excel, and run the macro by pressing Alt + F8, selecting "Convert_yyyymmddhhmmss_To_DateTime", and clicking Run. This macro will prompt you to select the range and then transform each 14-digit numeric string into an easily readable date-time value in-place.

Tips and troubleshooting:

  • If some values do not convert, check for length (should be exactly 14 digits), ensure no extra spaces, and confirm all values are numbers.
  • You can copy the converted date-time values to another column before running the macro if you wish to keep the originals intact.
  • Always save your workbook before running macros, and make sure macros are enabled in Excel.

Advantages: Quickly processes large ranges, easy to automate for repetitive tasks.
Disadvantages: Requires enabling macros, not always suitable in environments with macro security restrictions.


a screenshot of kutools for excel ai

Unlock Excel Magic with Kutools AI

  • Smart Execution: Perform cell operations, analyze data, and create charts—all driven by simple commands.
  • Custom Formulas: Generate tailored formulas to streamline your workflows.
  • VBA Coding: Write and implement VBA code effortlessly.
  • Formula Interpretation: Understand complex formulas with ease.
  • Text Translation: Break language barriers within your spreadsheets.
Enhance your Excel capabilities with AI-powered tools. Download Now and experience efficiency like never before!

Best Office Productivity Tools

🤖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 Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create 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 Ranges & Columns ...
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 Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

ExcelWordOutlookTabsPowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in