Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

M query - list.date from last year

I am looking for an M query for the previous year's first day and the first month of the year till today's function.

 

the date starts with 2020-01-01, 2020-01-02, 2020,01-03.... 2021-08-17 and if it's tomorrow then refresh change it to 2021-08-18, 2021-08-19, etc...

then 2022-01-01 then the date should start with 2021-01-01, not 2020-01-01

 

Thanks in advance!

 

  • let
        today = Date.From(DateTime.LocalNow()),
        start = #date(Date.Year(today)-1,1,1),
        Source = List.Dates(start, Duration.Days(today - start)+1, #duration(1,0,0,0))
    in
        Source

2 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion
    let
        today = Date.From(DateTime.LocalNow()),
        start = #date(Date.Year(today)-1,1,1),
        Source = List.Dates(start, Duration.Days(today - start)+1, #duration(1,0,0,0))
    in
        Source
    • Anonymous's avatar
      Anonymous
      Not applicable
       

      This works, thanks for quick solution