Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Datepicker Powerapps restrict selecting past days

Like (0) ShareShare
ReportReport
Posted on 27 Jan 2023 13:53:14 by 31

Hello,

 

Is there a way to restrict past days in datepicker. I want after date of 15th every month to disable selecting a date from previous month.

 

Let's say today is 15th January. I want to not be able to select a date from december, only from January. And when it will be 15th feb, i dont want to select a date from Jan.. and so on.

 

Can someone help? Thank you.

  • SteveAtTCH Profile Picture
    54 on 27 Jan 2023 at 14:07:12
    Re: Datepicker Powerapps restrict selecting past days

    hi @andrasetof30  ... I'm using the following code to only allow users to select a date from today, out 60 days... in my example below, my calendar is actually part of a gallery (which is why I'm referring to the selected date as ThisItem.Value)... but you can replace that reference with the name of your date picker (datepicker.selecteddate)...

    i know this isnt exactly the logic you're looking for, but hopefully this can give you a reference you can adjust for your scenario?

    If(
     Date(Year(ThisItem.Value), Month(ThisItem.Value), Day(ThisItem.Value)) >= DateValue(Now()) And 
     Date(Year(ThisItem.Value), Month(ThisItem.Value), Day(ThisItem.Value)) <= DateAdd(Now(), 60, Days), 
    
     < acceptable date logic goes here >,
    
     Notify("Only dates between " & DateValue(Now()) & " and " & DateAdd(Now(), 60, Days) & " will be accepted.", NotificationType.Error, 2000)
    )

     

  • Bilakanti Profile Picture
    1,226 on 27 Jan 2023 at 13:58:44
    Re: Datepicker Powerapps restrict selecting past days

    @andrasetof30 Currently canvas app datepicker control doesn't have that restriction, but as a workaround, on your datepicker onchange property you can write a logic to see if the selected date is less than the today, if yes, then notify the user and reset the control.

    Else- another option is to develop a custom PCF control and use it.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,780 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,093 Most Valuable Professional

Leaderboard
Loading started