Results 1 to 3 of 3

Thread: Power Query M: List of dates until day t is needed

  1. #1
    Seeker christiane.latte's Avatar
    Join Date
    Feb 2018
    Posts
    14
    Articles
    0
    Excel Version
    2016

    Power Query M: List of dates until day t is needed



    Register for a FREE account, and/
    or Log in to avoid these ads!

    What I did so far:

    Step 1:
    = List.Dates

    Step 2:
    = Source(#date(2018, 1, 1), Duration.Days(DateTime.Date(DateTime.FixedLocalNow())-#date(2017,12,31)), #duration(1, 0, 0, 0))

    But only gives me the dates until TODAY. (Well, of course: DateTime.FixedLocalNow()

    But how will it give me the days until this year's end? Or alternatively until next year's end?

    Can anyone help?

    Cheers,
    Chrissi

  2. #2
    Acolyte horseyride's Avatar
    Join Date
    Nov 2017
    Posts
    94
    Articles
    0
    Excel Version
    Office 365 Pro Plus 1708.8431.
    Code:
    let now = Date.From(DateTime.LocalNow()),
    yearend=  Date.From(Date.EndOfYear(DateTime.LocalNow())),
    nextyearend =  Date.AddYears(Date.From(Date.EndOfYear(DateTime.LocalNow())),1),
    list_until_end_year = List.Dates (now, Duration.Days(yearend-now)+1, #duration(1, 0, 0, 0)),
    list_until_next_end_year = List.Dates (now, Duration.Days(nextyearend-now)+1, #duration(1, 0, 0, 0))
    in list_until_next_end_year

  3. #3
    Seeker christiane.latte's Avatar
    Join Date
    Feb 2018
    Posts
    14
    Articles
    0
    Excel Version
    2016
    Brilliant! Thanks a gazillion!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •