Power Query Problems

How to Add Leading Zeros to Dates in Excel Power Query

Bushra ParveenBushra Parveen Nov 4, 2026 870 views

Question details

The user needs to add leading zeros to single-digit month and day values in Power Query to properly construct a standardized YYYYMMDD date format.

How to Add Leading Zeros to Dates in Power Query
Product
Excel Power Query
Device & OS
not provided
Scenario
Splitting date components into separate year, month, and day columns, or attempting to concatenate them into a custom string where months and days must uniformly display two digits.
Observed behavior
Month and day values extracted as single digits (e.g., '1' for January) lack the necessary leading zeros required for standard two-digit date formats.
Before you start

Ensure your target columns are formatted as Text rather than Whole Numbers, as text-padding functions in Power Query will result in errors if applied to numeric data types.

Solution 1Recommended

Use the Text.PadStart Function

Applying the Text.PadStart function is the most reliable way to enforce a two-character length for month and day columns by padding single digits with a zero.

The Text.PadStart function requires three arguments: the text string to evaluate, the total desired character length, and the character to use for padding. This approach is ideal for separated day and month columns.

1
Convert columns to text

In the Power Query Editor, select your Month or Day column. Right-click the column header, select 'Change Type', and click 'Text'. Replace current conversions if prompted.

2
Add a custom column

Navigate to the 'Add Column' tab on the top ribbon and select 'Custom Column'. A dialog box will appear.

3
Enter the padding formula

In the Custom Column Formula box, type the formula: = Text.PadStart([YourColumnName], 2, "0") and click OK. This will generate a new column with leading zeros applied to single digits.

Numeric Conversion Tip: If you prefer not to change the original column's data type, you can wrap it in Text.From directly within the formula: = Text.PadStart(Text.From([Month]), 2, "0").
Free Microsoft Office alternative

Simplify Data Manipulation with WPS Office

If you find Microsoft Excel's Power Query formulas complex and time-consuming, consider switching to WPS Office. It offers an intuitive, lightweight spreadsheet application with advanced data handling and formatting tools that don't require programming knowledge.

  1. 1. Download and install: Visit the official WPS Office website and install the free software suite.
  2. 2. Open your data file: Launch WPS Spreadsheet and easily import your Excel or CSV data files.
  3. 3. Format data seamlessly: Select your date columns, right-click to choose 'Format Cells', and easily apply standard or custom formatting.
Seamless format compatibility with Microsoft Excel (.xlsx, .xls, .csv)Intuitive formatting dialogs that eliminate the need for complex formulasCompletely free to download with a highly lightweight installation packageFamiliar user interface ensuring a zero learning curve for Excel users
microsoft office alternative - wps office

Frequently Asked Questions

Why does Text.PadStart result in an 'Expression.Error: We cannot convert the value to type Text'?

This error occurs because Text.PadStart only accepts text values, and your column is currently formatted as a whole number. You must either change the column type to Text or wrap your column reference in Text.From() within the formula.

Can I format dates as YYYYMMDD directly inside Power Query without converting to text?

No. Power Query treats a 'Date' data type uniformly and does not store display formats. To force a specific layout like YYYYMMDD inside Power Query, you must convert it to a Text string using Date.ToText. Otherwise, you format the date after loading it into the spreadsheet.

How do I combine the separate year, month, and day columns back together after adding leading zeros?

Once you have ensured the month and day columns are padded and formatted as text, you can combine them by adding a Custom Column and using the concatenation operator: = [Year] & [Month] & [Day].