Hello everyone,
I want calculate days between two dates in canvas app.
also want to excluding weekends and holidays but including last Saturday of the month.
i write below code for excluding weekends and including last Saturday of the month, i want to add logic of holiday list
can anyone please suggest me how to achieve this?
If(
StartDatePicker.SelectedDate = EndDatePicker.SelectedDate,
Text(
If(
[@DD_Half_Full_day].SelectedText.Value = "Half Day",
"0.5",
1 + ((DateDiff(
StartDatePicker.SelectedDate,
EndDatePicker.SelectedDate,
Days
)) * 5 - ((Weekday(StartDatePicker.SelectedDate) - Weekday(EndDatePicker.SelectedDate))*2)) / 7 - Switch(
Weekday(EndDatePicker.SelectedDate),
7,
1,
0
) - Switch(
Weekday(StartDatePicker.SelectedDate),
1,
1,
0
) + If(
(With(
{
NextMonth: DateAdd(
Date(
Year(Now()),
Month(Now()),
1
),
1,
Months
)
},
DateAdd(
NextMonth,
-1 * Weekday(
DateAdd(
NextMonth,
-7
)
)
)
) > StartDatePicker.SelectedDate - 1) && (With(
{
NextMonth: DateAdd(
Date(
Year(Now()),
Month(Now()),
1
),
1,
Months
)
},
DateAdd(
NextMonth,
-1 * Weekday(
DateAdd(
NextMonth,
-7
)
)
)
) < EndDatePicker.SelectedDate + 1),
1,
0
)
)
),
StartDatePicker.SelectedDate > EndDatePicker.SelectedDate,
"0",
Text(
1 + ((DateDiff(
StartDatePicker.SelectedDate,
EndDatePicker.SelectedDate,
Days
)) * 5 - ((Weekday(StartDatePicker.SelectedDate) - Weekday(EndDatePicker.SelectedDate))*2)) / 7 - Switch(
Weekday(EndDatePicker.SelectedDate),
7,
1,
0
) - Switch(
Weekday(EndDatePicker.SelectedDate),
1,
1,
0
) + If(
(With(
{
NextMonth: DateAdd(
Date(
Year(Now()),
Month(Now()),
1
),
1,
Months
)
},
DateAdd(
NextMonth,
-1 * Weekday(
DateAdd(
NextMonth,
-7
)
)
)
) > EndDatePicker.SelectedDate - 1) && (With(
{
NextMonth: DateAdd(
Date(
Year(Now()),
Month(Now()),
1
),
1,
Months
)
},
DateAdd(
NextMonth,
-1 * Weekday(
DateAdd(
NextMonth,
-7
)
)
)
) < EndDatePicker.SelectedDate + 1),
1,
0
)
)
)
also below is code for excluding holiday,
CountIf('Holiday List', Date >= StartDatePicker.SelectedDate, Date <= EndDatePicker.SelectedDate)
Thank you all in advance

Report
All responses (
Answers (