Forum Discussion

bernate's avatar
bernate
Icon for Helper III rankHelper III
3 years ago
Solved

Power Query Custom Column nth Day of Month

Hello, I am trying to create a custom column in Power Query that would display the date of the 2nd Monday in the month based on DateTime.LocalNow.

 

I think it will use Date.Year = DateTime.LocalNow, Date.Month = DateTime.LocalNow, Date.DayOfWeek = 1, and Date.WeekOfMonth = 2 but I'm not sure how to piece it all together. 

  • Here's one way to do it.

     

    = List.Select (List.Dates(Date.From(Date.StartOfMonth(DateTime.LocalNow())), 14, #duration(1,0,0,0)), each Date.DayOfWeekName(_)= "Monday"){1}

     

    Pat

2 Replies

  • ppm1's avatar
    ppm1
    Icon for Solution Sage rankSolution Sage

    Here's one way to do it.

     

    = List.Select (List.Dates(Date.From(Date.StartOfMonth(DateTime.LocalNow())), 14, #duration(1,0,0,0)), each Date.DayOfWeekName(_)= "Monday"){1}

     

    Pat

  • pls try this

     

    let
      Lists= List.Select(
        List.Dates(Date.From(Date.StartOfMonth(DateTime.LocalNow())), 14, #duration(1, 0, 0, 0)), 
        (x) => Date.DayOfWeek(x) = 0){1}
    in
      Lists