locked
How to calculate today's date? RRS feed

  • Question

  • Hello,

    I would like to learn how to calculate the duration between today's date from a start date in the past. How can I do this in the Power Query window?

    Friday, February 10, 2017 9:50 PM

Answers

  • No time component:
    = Duration.Days(DateTime.Date(DateTime.LocalNow())-#date(year,month,day))

    With time component:
    = DateTime.LocalNow()-#datetime(year,month,day,hours,minutes,seconds)

    Saturday, February 11, 2017 12:11 AM
  • You can use option "Age" under "Date" in the "Add Column" tab.
    (Also in the "Transform" tab, but then you loose your start dates).

    With all solutions, you must bear in mind that the result is the duration from the start date to the date at last refresh. It won't automatically update as time passes by.


    Saturday, February 11, 2017 3:48 AM

All replies

  • No time component:
    = Duration.Days(DateTime.Date(DateTime.LocalNow())-#date(year,month,day))

    With time component:
    = DateTime.LocalNow()-#datetime(year,month,day,hours,minutes,seconds)

    Saturday, February 11, 2017 12:11 AM
  • You can use option "Age" under "Date" in the "Add Column" tab.
    (Also in the "Transform" tab, but then you loose your start dates).

    With all solutions, you must bear in mind that the result is the duration from the start date to the date at last refresh. It won't automatically update as time passes by.


    Saturday, February 11, 2017 3:48 AM