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

Enable button only on weekdays between a certain time

Hi,

 

I have a button which should be enabled only on weekdays (i.e Saturday & Sunday it should be disabled) between a certain time.

 

For the button to be enabled between a time period I got it via this thread - https://powerusers.microsoft.com/t5/Building-Power-Apps/Toggle-button-visibility-between-Today-s-dat...

 

However not able to get how to enable a button only on weekdays.

 

Any help would be greatly appreciated.

 

Thanks. 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @TheOpeningBat ,

You need the TimeZoneOffset function, which returns the difference between UTC and the user's  device, for example India is +5.5 and UK is Zero (non-daylight saving) so the equation

-TimeZoneOffset(Now())/60

will get you the number of hours the user's device is ahead or behind UTC (for instance mine gives me 10 as I am in Eastern Australia Standard Time).

The below should give 8am in India

DateAdd(
    Now(),
    TimeZoneOffset() + 330,
    Minutes
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

Hi @TheOpeningBat ,

If you want (say) between 8:00am and 5:00 PM (actually 4:59:59) on weekdays

If(
   Hour(Now()) >=8 && Hour(Now()) <=16 && 
   Weekday(Today()) >=2 && Weekday(Today()) <=6, 
   DisplayMode.Edit, 
   DisplayMode.Disabled
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

TheOpeningBat
Helper III
Helper III

Hi @WarrenBelz ,

Thanks for your reply. The Weekday part is working fine. However for the time period part, if the app is getting used in multiple countries say India & UK then can we have the time period set to Indian Time.

Hi @TheOpeningBat ,

Just set the hours to suit (adjust for your time zone compared to India)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz - I mean to say - If app is getting used in multiple countries then the Now() part will display the local time right? But I want the time comparison based on Indian time so irrespective of where the the app is used - it should check for Indian time 8 to 5 & then enable/disable button.

Please suggest if I am missing something here.

Hi @TheOpeningBat ,

You need the TimeZoneOffset function, which returns the difference between UTC and the user's  device, for example India is +5.5 and UK is Zero (non-daylight saving) so the equation

-TimeZoneOffset(Now())/60

will get you the number of hours the user's device is ahead or behind UTC (for instance mine gives me 10 as I am in Eastern Australia Standard Time).

The below should give 8am in India

DateAdd(
    Now(),
    TimeZoneOffset() + 330,
    Minutes
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @TheOpeningBat ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

TheOpeningBat
Helper III
Helper III

Thanks @WarrenBelz. It really helped.

 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (2,295)