Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Function - get previous workday date

I am looking for some power query gurus help here , as am totally unfamiliar with M language .    i would need to create a function to get my previous working day date .  E.g. if today is May 31...
  • Fowmy's avatar
    5 years ago

    Anonymous 

    Add the following code as a new custom column: 

    let
      today = Date.From(DateTime.LocalNow()), 
      d     = Date.DayOfWeek(today, Day.Monday)
    in
      if d = 6 then
        Date.AddDays(today, - 2)
      else if d = 0 then
        Date.AddDays(today, - 3)
      else
        Date.AddDays(today, - 1)