Forum Discussion
Anonymous
3 years agoNot applicable
how to dynamically retrieve previous working day ?
Hello, This url gives me the french bank holidays : https://calendrier.api.gouv.fr/jours-feries/metropole.json Can you tell me how to write a function that takes a date as a parameter and returns t...
- 3 years ago
You can use this function
= (InputDate)=> let Source = Record.ToTable(Json.Document(Web.Contents("https://calendrier.api.gouv.fr/jours-feries/metropole.json"))), CalendarDates = List.Transform(Source[Name], each Date.From(_)), ListDates = List.Select(List.Dates(#date(1899,12,30), Duration.Days(Date.From(InputDate)-#date(1899,12,30)), #duration(1,0,0,0)), each Date.DayOfWeek(_,1)<5), PreviousWorkDay = List.Last(List.Difference(ListDates, CalendarDates)) in PreviousWorkDay
Vijay_A_Verma
3 years agoMost Valuable Professional
You can use this function
= (InputDate)=>
let
Source = Record.ToTable(Json.Document(Web.Contents("https://calendrier.api.gouv.fr/jours-feries/metropole.json"))),
CalendarDates = List.Transform(Source[Name], each Date.From(_)),
ListDates = List.Select(List.Dates(#date(1899,12,30), Duration.Days(Date.From(InputDate)-#date(1899,12,30)), #duration(1,0,0,0)), each Date.DayOfWeek(_,1)<5),
PreviousWorkDay = List.Last(List.Difference(ListDates, CalendarDates))
in
PreviousWorkDayAnonymous
3 years agoNot applicable
Thank you !
I have a similar question here https://community.powerbi.com/t5/Power-Query/how-to-dynamically-calculate-the-difference-between-2-dates/m-p/3159154#M101380 if you have a little time.