Quick #PowerQuery trick – Get duration days between two dates

Just a quick tip that you might not be aware of in the Power Query Editor.

If you select two columns in the view and on the Add Column tab, select the Date button – you can select to Subtract Days

This will give you the number of days between the dates in the selected columns

Use the formula bar to rename the new column by modifying the step

 

Hope this can help you too –

8 thoughts on “Quick #PowerQuery trick – Get duration days between two dates

  1. Hi – interesting – is there a reason you wouldn’t use datediff function? I’m asking as when i use datediff against redshift database it gives me some rows correct and others a big negative number. If i use your method it does seem to correctly calculate. i wonder if there’s an issue with datediff. thanks!

  2. Hi Erik, I have the same Question as Patrick. What i’d only like to see the Workdays (No holidays, no weekenddays) between the two columns?

    1. Hi Steve

      Do you have a dates table that has columns containing weekday number and an indication of the date is a holiday ?

      If you have then you can add a calculated column that contains a formula something like this Table.Rowcount(table.selectrows(datetable, each
      [date] >= [StartDate] and [date] <= [enddate] and [weekday] <=5 and [Holiday] = false))

      Answering via phone so no M intellisense 🙂

      Best
      Erik

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s