web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Restricting a date picker
Power Apps
Answered

Restricting a date picker

(0) ShareShare
ReportReport
Posted on by 260

Hello

 

I have a time sheet solution that works well, but it has a fatal flaw. The start of the week has to be a Saturday. 

 

Normally this is fine. The date picker defaults to the past Saturday with this code, so when the user is creating this week's timesheet that is fine

 

DateAdd(
 Today(),
 1 - Weekday(
 Today(),
 StartOfWeek.Saturday
 )
)

 

 

The problem occurs if they need to complete the previous week's timesheet too. They are instructed to pick Saturday, but nothing actually stops them from picking anything else.

 

I don't expect to be able to restrict the actual date picker, but I do think having a condition in the "Continue" button that checks the date picker and only allows navigation to the next page if the user has picked a Saturday, otherwise prompts the user to make the correct choice is possible

Can someone help me with the If statement

 

Thank you very much

Conn

Categories:
  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    try this in the displaymode of a button to see how it works, then adjust to your needs.

     

    Switch(Weekday(DatePicker1.SelectedDate), 
     7, DisplayMode.Edit, DisplayMode.Disabled)

     

    that shoudl only unlock the button when they weekday is 7 (saturday) If you have changed your datepicker settings to make start of week saturday, you may need to change the 7 to 1 (you do this in the StartOfWeek setting on datepicker control, you would know if you did)

    I have also made a custom calendar control, that is in this test app, where you can set only certain days of the weeks to be selectable at all. you can also use this

  • ConnM Profile Picture
    260 on at

    Brilliant Rob

     

    Thank you for the speedy solution. I did indeed change the start of the week to try to make it obvious for the team, but this has taken away all risk of error.
    I'll add in a tooltip and I'm ready to go

     

    Your calendar looks really cool. I won't use it for this app, but I will keep it in mind in the future

     

    Thank you very much

    Conn 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard