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 III
Super User III

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.

View solution in original post

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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 (2,217)