cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Aurora
Helper V
Helper V

Hide button based on date input

Hi all, 

 

I was hoping this would be simple, but I am still struggling to figure it out. I have a button in an app that prevents the user from selecting it if they enter a date more than 1 day in the past. All I need to do, is add the same functionality but this time for days in the future. 

 

An example: A user cannot submit a form if they input the dates (9/18/2021) or (9/22/2021) if they are using the app on (9/20/2021)

 

I am currently using this function to prevent the submit button from being accessed if the selected date is in the past: 

If(DateDiff(DataCardValue18.SelectedDate, Today(),Days) > 1, DisplayMode.Disabled, Edit)

 

If anyone knows how to get the same result for future dates, please let me know!

1 ACCEPTED SOLUTION

Accepted Solutions
BCLS776
Super User
Super User

This will work for DateDiff generating a negative number of days too:

 

If(Abs(DateDiff(DataCardValue18.SelectedDate, Today(),Days)) > 1, DisplayMode.Disabled, DisplayMode.Edit)

 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

1 REPLY 1
BCLS776
Super User
Super User

This will work for DateDiff generating a negative number of days too:

 

If(Abs(DateDiff(DataCardValue18.SelectedDate, Today(),Days)) > 1, DisplayMode.Disabled, DisplayMode.Edit)

 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,580)