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

Having trouble disabling button based on date

I am trying to disable a button based on a date.  What i need is the button to be disabled on December 1-January 10 every year.  Then on the 10th or 11th of January, the button goes into Edit mode again.

 

I've tried a few post suggestions but have been unsuccessful so far.  tried doing a If statement with today() and i apparently am missing something.

 

Anyone have suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @Km00,

Have you solved your problem?

Do you want to set the DisplayMode property of a button based on a specific date range?

Could you please share a bit more about the scenario?

I think the key to this issue is to extract the month and day of the current date, please check Month() and Day() here.

I have made a simple test for you, please take a try as below.

Set the DisplayMode property of the icon as below:

 

If(
    Month(Today()) = 12 || (Month(Today()) = 1 && (Day(Today()) >= 1 && Day(Today()) <= 10)),
    Disabled,
    Edit
)

 

Check if this could help you at some degree.

 

Best Regards,
Qi

View solution in original post

3 REPLIES 3
zmansuri
Super User
Super User

Since you have fixed set of dates. I suggest you make a hard coded collection of dates or make a separate list of dates. Then on App.OnStart check Today() against that collection. 

All you have to be careful is the format of the date. You can take a label to check that format of date is correct on both side.

You condition can be like this;

Set(IsDate,Filter(collectionName,Today() in DateColumnName)

 

on your button default mode property you can write

If(IsBlank(IsDate),DisplayMode.Edit,DisplayMode.Disable)

 

This way your button will be disable if there is some value in variable IsDate.

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

v-qiaqi-msft
Community Support
Community Support

Hi @Km00,

Have you solved your problem?

Do you want to set the DisplayMode property of a button based on a specific date range?

Could you please share a bit more about the scenario?

I think the key to this issue is to extract the month and day of the current date, please check Month() and Day() here.

I have made a simple test for you, please take a try as below.

Set the DisplayMode property of the icon as below:

 

If(
    Month(Today()) = 12 || (Month(Today()) = 1 && (Day(Today()) >= 1 && Day(Today()) <= 10)),
    Disabled,
    Edit
)

 

Check if this could help you at some degree.

 

Best Regards,
Qi

This worked!! Thank you.  I did try the first suggestion and in a roundabout way i was able to make that work but with the second suggestion I am able to remove the extra list and not have to deal with the year which is great.

 

Thank you!!!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,189)