none
Number of Days between Two Dates RRS feed

  • Question

  • Hi -- I am trying to calculate the number of days that have passed between a start date and a column with the "today" formula in it, so that I can multiply another column by that number of days between those dates. Is there a power query formula to do this? 

    

    

    I used this formula from another post but I keep getting an error, and I don't want to dd another table

    =Table.AddColumn(Source, "Duration", each [Date1] - [Date2])

    source -- https://social.technet.microsoft.com/Forums/en-US/f58b2080-5824-4f18-be1c-beac06a2fdfc/power-query-durration-days-between-two-columns?forum=powerquery 

    Thank you!

    Tuesday, September 27, 2016 3:26 PM

Answers

  • Hi sraschh. Since you're column names are different, the formula should be:

    =Table.AddColumn(Source, "Duration", each [Today] - [Date Implemented])

    Does that work?

    That said, you should be able to generate the formula you're looking for via UI (without having to write custom M) by doing the following:

    • Select the Today column
    • Ctrl+Select the Date Implemented column
    • In the ribbon, click the Add Column tab, then Date->Subtract Days

    Ehren

    Tuesday, September 27, 2016 4:50 PM
    Owner

All replies

  • Hi sraschh. Since you're column names are different, the formula should be:

    =Table.AddColumn(Source, "Duration", each [Today] - [Date Implemented])

    Does that work?

    That said, you should be able to generate the formula you're looking for via UI (without having to write custom M) by doing the following:

    • Select the Today column
    • Ctrl+Select the Date Implemented column
    • In the ribbon, click the Add Column tab, then Date->Subtract Days

    Ehren

    Tuesday, September 27, 2016 4:50 PM
    Owner
  • Hi Ehren - yes, I had tried the custom M code with my column headers without success before posting here. However -- your method of doing this without the custom code, just the add a column button, worked great. Thanks so much for your help! 

    Wednesday, September 28, 2016 5:57 PM