Forum Discussion

askspepsi's avatar
askspepsi
Helper II
5 years ago
Solved

Power Query Start date to today

Greeting All,

 

IdStart DateDate Master
101/05/202101/05/2021
101/05/202102/05/2021
101/05/202103/05/2021
101/05/202104/05/2021
101/05/202105/05/2021
101/05/202106/05/2021
101/05/202107/05/2021
101/05/202108/05/2021
101/05/202109/05/2021
101/05/202110/05/2021
101/05/202111/05/2021
101/05/202112/05/2021
101/05/202113/05/2021
101/05/202114/05/2021
101/05/202115/05/2021
101/05/202116/05/2021
101/05/202117/05/2021
101/05/202118/05/2021
101/05/202119/05/2021
101/05/202120/05/2021
101/05/202121/05/2021
101/05/202122/05/2021
101/05/202123/05/2021
101/05/202124/05/2021
101/05/202125/05/2021
101/05/202126/05/2021
101/05/202127/05/2021
211/05/202111/05/2021
211/05/202112/05/2021
211/05/202113/05/2021
211/05/202114/05/2021
211/05/202115/05/2021
211/05/202116/05/2021
211/05/202117/05/2021
211/05/202118/05/2021
211/05/202119/05/2021
211/05/202120/05/2021
211/05/202121/05/2021
211/05/202122/05/2021
211/05/202123/05/2021
211/05/202124/05/2021
211/05/202125/05/2021
211/05/202126/05/2021
211/05/202127/05/2021

 

I have used the below query for 100days but I want to add today() function instead of 100.

Date Master=List.Dates([Start Date], 100, #duration(1, 0, 0, 0))

 

Please help to change this Query.

 

Thank you,

askspepsi

  • askspepsi 

    Your formula is creating a list of dates from [Start Date] with 100 days. IF not 100 days, what exactly is required there?
    Today is a Date, you a number. if you need today's date in PQ Date.From(DateTimeZone.LocalNow())

5 Replies

  • askspepsi , Try like

    Date Master=List.Dates([Start Date], Duration.Days(today() -[Start Date]) , #duration(1, 0, 0, 0))

    • askspepsi's avatar
      askspepsi
      Helper II

      amitchandak 

      I have got the below error

      Expression.Error: The name 'today' wasn't recognized. Make sure it's spelled correctly.

  • askspepsi 

    Your formula is creating a list of dates from [Start Date] with 100 days. IF not 100 days, what exactly is required there?
    Today is a Date, you a number. if you need today's date in PQ Date.From(DateTimeZone.LocalNow())

    • askspepsi's avatar
      askspepsi
      Helper II

      Fowmy 

      You are correct, my formula is creating for 100days, but for time being and to make the formula work I kept as 100days, but in reality, it should take today's date for example:- one employee starts from May 1st, 2021 then the date master should have 1st May 2021 to 27th May 2021 and when it is tomorrow the date master should be 1st May 2021 to 28 May 2021.

       

      As you said to use Date.From(DateTimeZone.LocalNow()),

      My Formula is now working fine, Thank you.

      List.Dates([Start Date], Duration.Days(Date.From(DateTimeZone.LocalNow()) -[Start Date])+1 , #duration(1, 0, 0, 0))