Finding difference between two dates (containing timestamp) - exclude weekends in the calculation

• Question

• Hi !

How would this be possible to do ?
I have 2 columns "Start Date" and "End Date" that contains time stamp (for example: 5/6/2019 4:46:00 PM). I would like to take the difference of the two dates to calculate number of days (including hours which will most likely be contained as part of decimals). I also want to ensure weekends are excluded.

-Sam

Thursday, August 15, 2019 5:36 AM

• You can add a column with this code:

[
ListOfAllDays = List.Dates(Date.From([DateStart]), Number.From(Date.From([DateEnd]) - Date.From([DateStart])) + 1, #duration(1,0,0,0)),
NumberOfWeekdays = List.Count(List.Select(ListOfAllDays, (x) => Date.DayOfWeek(x, Day.Monday) < 5 )),
StartAdjustment = if Date.DayOfWeek([DateStart], Day.Monday) < 5 then Number.From(Time.From([DateStart])) else 0,
EndAdjustment = if Date.DayOfWeek([DateEnd], Day.Monday) < 5 then 1 - Number.From(Time.From([DateEnd])) else 0,