Summary
I needed to restrict the date selection in the Power Apps form to only allow Tuesday and Thursday.
Step By Step Solution
I assume you know how to create Power Apps form app.
Step # 1 I the BorderColor property of the Date control (in my case DateValue2) put the following formula. The Weekday function will provide the number for Tue and Thu.
// if parent error is blank or
// selected date is Tue or Thu the border color is normal
If(
Coalesce(
(Weekday(
DateValue2.SelectedDate,
StartOfWeek.Sunday
) = 3) ||
(Weekday(
DateValue2.SelectedDate,
StartOfWeek.Sunday
) = 5),
IsBlank(Parent.Error)
),
Parent.BorderColor,
Color.Red
)
Step # 2 In the Text property of the ErrorMessage Control of the DataCard add the following formula.
Coalesce(
Parent.Error,
If(
((Weekday(
DateValue2.SelectedDate,
StartOfWeek.Sunday
) <> 5) && (Weekday(
DateValue2.SelectedDate,
StartOfWeek.Sunday
) <> 3)),
"Date must be for Tuesday or Thursday only"
)
)
Conclusion
Currently, the out of the box date control does not provide any validation, this is an alternative approach to validate and restrict the days. I hope it is useful to you for your scenario.