Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Suggested answer

DatePicker with Minimum and Maximum date ranges

Like (1) ShareShare
ReportReport
Posted on 9 Sep 2024 02:43:18 by 380
Hi,
 
Is it possible to set max and min date ranges to select for date picker? Remaining dates should be greyed out. 
There are no MaxDate and MinDate properties for date picker control in PowerApps. Is there any other way to achieve this? Any suggestion would be greatly appreciated.
 
Thank you,
 
  • OK29 Profile Picture
    OK29 380 on 12 Sep 2024 at 11:52:19
    DatePicker with Minimum and Maximum date ranges
    @FLMike, Thank you for your comments. I tried but I am getting error message that "A property cannot reference itself or other properties effected by its value" once I enter the below function in defaultdate property.
     
    This date picker is in a data control.
     
    Did you try this at your end?
  • Ravindra Jadhav Profile Picture
    Ravindra Jadhav 240 on 09 Sep 2024 at 06:29:26
    DatePicker with Minimum and Maximum date ranges
    Thanks @Flmike
     
     
  • Suggested answer
    FLMike Profile Picture
    FLMike 27,286 on 09 Sep 2024 at 04:32:55
    DatePicker with Minimum and Maximum date ranges
    Hi,
     
    Yes, you can change the DefaultDate Property so that it doesn't allow you to do that.
     
    Example
     
    Let's pretend you do not want to go backwards more then 10 days and Forward more than 10 days from Today.
     
    You need to have "something" store the DefaultDate which acts as your starting point.
    So an Example
     
    In my OnVisible of the Screen, where this control exists I do this
     
    Set(_DefaultDate, Now());
     
    This will simply allow us to understand the initial date to subtract and add days too, too see if they are too far before or after the dates you want.
     
    In your DefaultDate Property of the DatePicker we need to do this
     
    If( DateDiff(Self.SelectedDate, _DefaultDate,TimeUnit.Days) > 10 days Or DateDiff(YourDate, Self.SelectedDate, TimeUnit.Days) > 10,
       _DefaultDate,
    );
     
    What the above does is, it checks to see if whatever date they picked is greater than 10 days in either direction.
    and if so resets it to the _DefaultDate from the Variable you create. If it is NOT greater than 10 then it lets them keep what they selected
     
    You can certainly create Environment Variables or some sharepoint config list, to store the Number, this way you can change it whenever.
          
    Cheers,
     
     

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

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,696

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,456

Leaderboard
Loading started
Loading complete