Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Date.AddDays: How to Add Days to Dates

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Date.AddDays in Power Query adds a whole number of days to a date, datetime, or datetimezone value and returns the shifted value. The syntax is Date.AddDays(dateTime, numberOfDays): a positive number moves forward, a negative number moves backward. It is a built-in function in the M language, so you can use it in a custom column, in the formula bar, or in a query step without installing anything.

What You'll Need

  • Power BI Desktop, Excel with Power Query (Data > Get & Transform Data), or another host that includes the Power Query Editor.
  • A query that already contains a date, datetime, or datetimezone column, or a step where you can enter an M formula.
  • Basic familiarity with the Power Query Editor: the Queries pane, the Applied Steps list, and the formula bar (enable it under View if it is hidden).

Menu labels and button names can differ slightly between Power BI versions, Excel versions, and regions, but the function itself behaves the same everywhere.

Step-by-Step

  1. Open the Power Query Editor. In Power BI, select Transform data on the Home ribbon. In Excel, go to Data > Get & Transform Data > Launch Power Query Editor.
  2. Load the table that contains your date column, or select the query in the Queries pane.
  3. Confirm the column's data type. Select the column header; the icon on the left of the header shows the type. If it shows ABC/123 or a calendar icon, the column is text or date. For Date.AddDays to work, the column should be Date, Date/Time, or Date/Time/Zone. If it is text, use Transform > Data Type > Date (or Date/Time) first, and resolve any errors that appear.
  4. Add a custom column. On the Add Column tab, select Custom Column. Give it a name such as Shifted Date.
  5. In the Custom Column formula box, enter a formula that calls the function. For a column named OrderDate, type:
    Date.AddDays([OrderDate], 7)
    Replace 7 with the number of days you want. Use a negative number to subtract days, for example Date.AddDays([OrderDate], -3).
  6. Select OK. Power Query adds the new column and a step in Applied Steps. If you see an error in a row, the usual cause is a null or a value that is not a date; see Troubleshooting below.
  7. Set the new column's data type. Select the new column header, then choose Date (or Date/Time) from the data type menu. The result of Date.AddDays keeps the input type, but setting it explicitly prevents surprises downstream.
  8. Check the result against a known row. For example, if OrderDate is 15 January and you add 7, the result should be 22 January. If the result is off by one, check whether your source stores dates as text or in a different locale format.
  9. Rename the step if you like, then select Close & Load (or Close & Apply) to load the query back to your workbook or data model.

To use the function in the formula bar instead of a custom column, select an existing step, then edit the formula so the step returns Date.AddDays(...). This is more advanced and easy to break, so the custom column route is safer for most users.

Common Mistakes

  • Passing a text value. Date.AddDays expects a date, datetime, or datetimezone value. A text column such as "2024-01-15" will error until you change its type to Date.
  • Using a decimal. The number of days must be a whole number. Date.AddDays([OrderDate], 1.5) returns an error; round or use a different function if you need partial days.
  • Forgetting nulls. A null date returns null, not an error, but a null in the days argument also returns null. Decide whether that is acceptable or filter those rows out.
  • Assuming it changes the original column. Date.AddDays returns a new value. You must add a custom column or replace the existing column's values with the formula result.
  • Mixing up Date.AddDays with Duration.Days. Date.AddDays shifts a date; Duration.Days extracts a number of days from a duration. They are not interchangeable.
  • Ignoring time zones. For datetimezone values, the function shifts the date and keeps the zone offset. If you expected a local-time conversion, you need a different step.

Tips

  • Use a parameter instead of a hard-coded number if you want to change the offset later. Create a parameter in Manage Parameters, then reference it in the formula, for example Date.AddDays([OrderDate], DayOffset).
  • To add months or years, use Date.AddMonths or Date.AddYears rather than multiplying days, because month lengths vary.
  • To add a fixed number of days to today's date, use Date.AddDays(DateTime.LocalNow(), 30). The result is a datetime, so set the type if you only need the date.
  • For weekday-only shifts, Date.AddDays alone is not enough; you need to combine it with logic that skips weekends. Plan that as a separate custom column.
  • Keep the original date column until you have verified the new one. Deleting the source column too early makes errors harder to trace.

Troubleshooting

The formula returns an error on some rows. Select the error cell to see the message. If it says the value is not a date, change the source column's type to Date or Date/Time. If the source contains text in mixed formats, clean it first, for example by splitting or replacing characters, then set the type.

The result is null. Check whether the source date is null and whether the days argument is null. Null in, null out is expected behaviour.

The function is not recognised. Check spelling and capitalisation: it is Date.AddDays with a capital D in both words. Also confirm you are in the Power Query Editor, not in a DAX formula bar; DAX uses a different function name.

The new column shows the wrong type. Set the data type explicitly on the new column header. If the result shows a time component you do not want, change the type to Date.

If that did not work, duplicate the query, remove the custom column step, and rebuild it one step at a time. This isolates which step introduces the error. As a last resort, close without applying, reopen the file, and repeat the steps; do not delete the original query until the new one loads correctly.

Frequently Asked Questions

Can Date.AddDays subtract days?

Yes. Pass a negative number, such as Date.AddDays([OrderDate], -10), to move the date backward.

Does Date.AddDays work on a datetime column?

Yes. It accepts date, datetime, and datetimezone values and returns the same type with the day shifted. The time portion is preserved.

Why does my formula return an error about the number of days?

The days argument must be a whole number. Decimals, text, and nulls cause errors or null results. Round the value or change its type first.

Can I add days to today's date automatically?

Yes. Use Date.AddDays(DateTime.LocalNow(), 30) for 30 days from now. The result is a datetime, so set the column type to Date if you only need the date.

Is Date.AddDays available in Excel Power Query?

Yes. It is part of the M language used by Power Query in Excel, Power BI, and other hosts that embed Power Query. The editor layout differs, but the function is the same.

What is the difference between Date.AddDays and Date.AddMonths?

Date.AddDays adds a fixed number of days, while Date.AddMonths adds calendar months and handles different month lengths. Use the one that matches your business rule.