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 / Limit a date selector ...
Power Apps
Answered

Limit a date selector to only sundays

(0) ShareShare
ReportReport
Posted on by 3,224

I want to limit users to selecting just sundays in a date selector for week date in a canvas app. Can I do that?

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @jlindstrom 
    The DatePicker control does not have any ability to restrict days of the week.  There's many limitations to datepickers currently...

     

    You could check whether a Sunday was picked using this code.

    If(Weekday(DatePicker1.SelectedDate)=1, "Valid date", "Not a valid date")



    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • cchannon Profile Picture
    4,702 Moderator on at

    Alternatively, if you are ready to really dig in, you could build your own date picker control in PCF that allows only the selection of Sundays.

     

    Start with this control from the PCF Gallery and if would just take a few lines of JS validation to prevent selection of any dates that aren't a Sunday (Bonus: it looks a heck of a lot nicer than the OOB date picker).  If you've built a PCF before, it should take you no more than an hour.

  • mdevaney Profile Picture
    29,991 Moderator on at

    @cchannon 

    Is PCF only for model-driven apps?

    (I feel like this could be built in canvas too.  Maybe it would make a good weekend project)

  • cchannon Profile Picture
    4,702 Moderator on at

    PCF is available for canvas apps in Preview right now. The main limitation you will hit there will be that there is no access to the WebApi, so if you want any custom database operations to happen inside your control, you will need to get creative with outputs and passing values back up to your canvas app to take actions ( pcf assign output params for canvas app operations ) . But overall, I have found it is pretty stable and easy to use. Check the Powerapps pro dev & ISV channel on this community for tons of discussions and resources, plus, I would recommend you take a look at some of the following:

     

    https://docs.microsoft.com/en-us/powerapps/developer/component-framework/create-custom-controls-using-pcf

    https://pcf.gallery/

    and, if you're going to try to use FluentUI as in the PCF Gallery example I posted above, you will want

    https://developer.microsoft.com/en-us/fluentui#/

    https://reactjs.org/tutorial/tutorial.html  <- Seriously. If you are going to try to use React in a PCF, start here.

     

    Enjoy!

  • Verified answer
    Joel CustomerEffective Profile Picture
    3,224 on at

    Thanks @mdevaney and @cchannon . I rethought the requirement and what I really need is the Sunday of the week, so I can let the users select whatever date they want to, then use the following in another date field to get the Sunday of the week.

     

    DatePicker1.SelectedDate-Weekday(DatePicker1.SelectedDate,2)

  • jamiekim Profile Picture
    125 on at

    Where should this code be input?  Into the "On Select" property of the Submit button? 

  • yashp1196 Profile Picture
    27 on at

    What about Saturday? 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 490

#2
WarrenBelz Profile Picture

WarrenBelz 427 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 381

Last 30 days Overall leaderboard