Power Query Problems

How to Convert Text Log Dates and Times in Excel Using Power Query

Huda QurayshiHuda Qurayshi Nov 3, 2026 871 views

Question details

The user needs a reliable method to convert text strings representing dates and times from log files into proper Excel date and time values.

How to Convert Text Log Dates and Times in Excel Using Power Query
Product
Microsoft Excel
Device & OS
not provided
Scenario
Importing and analyzing system or application log files that contain poorly formatted, text-based date and time stamps.
Observed behavior
Excel fails to interpret the text dates consistently due to leading spaces and ambiguous formats (such as '10/26/19 3:19 PM'), treating them as plain text instead of calculable values.
Before you start

Ensure that your raw log data is structured in an identifiable column and that you know the origin region of your data (e.g., US format Month/Day/Year vs UK format Day/Month/Year).

Solution 1Recommended

Use Power Query and Locale Settings to Clean Text Dates

This is the most robust method for handling dates and times, as it removes unwanted spaces and strictly defines the regional date format to prevent parsing errors.

Power Query is ideal for cleaning log files because you can record the transformation steps and automatically repeat them for future imports. Using the 'Locale' feature ensures Excel correctly interprets ambiguous month and day placements.

1
Import the Data to Power Query

Select your log file data, navigate to the 'Data' tab on the ribbon, and click 'From Table/Range' to open the Power Query Editor.

2
Trim Leading Spaces

Right-click the column header containing the text dates, select 'Transform', and click 'Trim'. This removes any hidden spaces that prevent Excel from recognizing the date.

3
Change Data Type using Locale

Right-click the column header again, select 'Change Type', and choose 'Using Locale...'. In the dialog box, set the Data Type to 'Date/Time' and select the matching regional format (e.g., 'English (United States)' for MDY formats). Click OK.

4
Load to a New Worksheet

To avoid formatting conflicts with your original data, click 'Close & Load To...' in the top-left corner and select 'New Worksheet'.

Preventing Formatting Issues: Loading the query results into a fresh sheet usually circumvents cell formatting glitches that occur when overwriting the original text data.
Easy Data Transformation

Convert Text Dates to Real Dates Using WPS Spreadsheet

WPS Spreadsheet provides powerful, user-friendly data tools like Text to Columns and advanced cell formatting to easily clean log file dates. It is a highly efficient, free alternative for your daily data processing needs.

  1. 1. Open Your Log File: Launch WPS Spreadsheet and open the log file (.csv or .xlsx) containing your inconsistently formatted text dates.
  2. 2. Clean Leading Spaces: Highlight the date column, press Ctrl+H to open the Find and Replace tool, and clear out the leading spaces by replacing them with nothing.
  3. 3. Apply Text to Columns: Navigate to the 'Data' tab and click 'Text to Columns'. Select 'Delimited', apply your delimiters, and set the destination format to 'Date (MDY)'.
  4. 4. Format the Final Cells: Right-click your newly split date data, choose 'Format Cells', and select your preferred Date and Time layout to finalize the conversion.
Seamlessly compatible with Microsoft Excel (.xlsx and .csv) formats without data lossBuilt-in Text to Columns and Find & Replace tools for rapid log file cleaningLightweight architecture that processes large log files smoothly even on older devices
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel fail to recognize my log file dates?

Excel relies on specific system locale settings and strict parsing rules. Leading spaces, text-based timestamps, or non-standard orders (like reading MM/DD/YY when the system expects DD/MM/YY) cause Excel to treat these entries as raw text instead of actual dates.

How do I fix the formatting error when loading Power Query data back to Excel?

When loading transformed data from Power Query, choosing to load it into a 'New Worksheet' rather than overwriting the original location often prevents underlying cell formatting conflicts and table structure errors.

Can I convert text dates without using Power Query?

Yes. You can use the 'Text to Columns' feature under the Data tab. By choosing delimited data and specifying the exact date structure (like MDY) in Step 3 of the wizard, you can successfully convert text strings into standard dates.

What does changing the locale in Power Query do?

Changing the locale allows Power Query to interpret dates based on regional standards. For example, using US English tells the system to read '10/26' as October 26th, preventing errors where the software would normally expect the day to come before the month.