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 / control the datepicker
Power Apps
Answered

control the datepicker

(0) ShareShare
ReportReport
Posted on by

I have a date picker in the power app, I need to control where not allowed to select the previous days and the two days after today and allow them to select only within two months only

 

for example, today is 21 - May - 2024

any day the previous 21 are not allowed

and 22 and 23 may also not be allowed

the allowed day is between 24 May to 24 June

and any other days are disabled

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,791 Most Valuable Professional on at

    Hi @noor12 ,

    You cannot stop the user selecting a Date, however you can stop them saving it - put this OnChange

    With(
     {
     _Diff:
     DateDiff(
     Self.SelectedDate,
     Today(),
     TimeUnit.Days
     )
     },
     If(
     !(_Days > 3 && _Days <= 30),
     Notify(
     "Date not allowed",
     NotificationType.Error
     );
     Reset(Self)
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • noor12 Profile Picture
    on at

    noor12_0-1716292046700.png

    it show me this error

  • Gochix Profile Picture
    1,935 Moderator on at

    @noor12 ,

     

    Just a small typo.

    With(
     {
     _Diff:
     DateDiff(
     Self.SelectedDate,
     Today()
     TimeUnit.Days
     )
     },
     If(
     !(_Diff > 3 && _Diff <= 30),
     Notify(
     "Date not allowed",
     NotificationType.Error
     );
     Reset(Self)
     )
    )
  • noor12 Profile Picture
    on at

    noor12_0-1716292238041.png

     

  • Verified answer
    Gochix Profile Picture
    1,935 Moderator on at
    With(
     {
     _Diff:
     DateDiff(
     Self.SelectedDate,
     Today(),
     TimeUnit.Days
     )
     },
     If(
     !(_Diff > 3 && _Diff <= 30),
     Notify(
     "Date not allowed",
     NotificationType.Error
     );
     Reset(Self)
     )
    )
  • WarrenBelz Profile Picture
    153,791 Most Valuable Professional on at

    @noor12 ,

    Just missing a comma (now fixed) - I thought you might have spotted that.

  • Gochix Profile Picture
    1,935 Moderator on at

    @noor12 ,

    Please accept @WarrenBelz solution, I just fixed the typo.

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!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 70

#2
WarrenBelz Profile Picture

WarrenBelz 64 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 36 Super User 2026 Season 1

Last 30 days Overall leaderboard