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

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.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,593)