cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Karol
Helper II
Helper II

DatePicker restrict weekend days (Saturday & Sunday)

Hello,


In my scenario I want to prevent users from selecting a Saturday or Sunday in datepicker in my "Required by date" column.

 

I defined on OnVisible Screen:

 

If(
    Weekday(
        Today() + 3,
        StartOfWeek.Sunday
    ) = 1,
    Set(
        varDate,
        Today() + 4
    ),
    Weekday(
        Today() + 3,
        StartOfWeek.Sunday
    ) = 7,
    Set(
        varDate,
        Today() + 5
    ),
    Weekday(
        Today() + 3,
        StartOfWeek.Sunday
    ) <> 7 && Weekday(
        Today() + 3,
        StartOfWeek.Sunday
    ) <> 1,
    Set(
        varDate,
        Today() + 3
    )
)

 

 

What should I do now to achieve my plan? I would like to give users an error message, when they click on Saturday and Sunday in DatePicker.

 

Karol_0-1637501533861.png

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
AmDev
Super User
Super User

Hi @Karol 

 

You can achieve this with the following code in your date picker:

 

  • Onselect: Set(varDate, Self.SelectedDate)
  • DefaultDate: If(Weekday(varDate) =1 || Weekday(varDate) =7, Blank(), varDate)
  • InputTextPlaceholder: If(IsBlank(Self.SelectedDate), Text("DD/MM/YYYY"))

 

In terms of your error message, you could set it's visibility to Weekday(varDate) =1 || Weekday(varDate) =7. i.e. it will then disappear when the user selects weekday between 2 and 6.

 

Hope this helps - good luck!

View solution in original post

1 REPLY 1
AmDev
Super User
Super User

Hi @Karol 

 

You can achieve this with the following code in your date picker:

 

  • Onselect: Set(varDate, Self.SelectedDate)
  • DefaultDate: If(Weekday(varDate) =1 || Weekday(varDate) =7, Blank(), varDate)
  • InputTextPlaceholder: If(IsBlank(Self.SelectedDate), Text("DD/MM/YYYY"))

 

In terms of your error message, you could set it's visibility to Weekday(varDate) =1 || Weekday(varDate) =7. i.e. it will then disappear when the user selects weekday between 2 and 6.

 

Hope this helps - good luck!

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (3,769)