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

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
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,011)