web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Enable button only on ...
Power Apps
Answered

Enable button only on weekdays between a certain time

(0) ShareShare
ReportReport
Posted on by 130

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-date-9-AM-to-11-55-PM/m-p/834627#M265483

 

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

 

Any help would be greatly appreciated.

 

Thanks. 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,408 Most Valuable Professional on at

    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 Profile Picture
    130 on at

    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.

  • WarrenBelz Profile Picture
    153,408 Most Valuable Professional on at

    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.

  • TheOpeningBat Profile Picture
    130 on at

    @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.

  • Verified answer
    WarrenBelz Profile Picture
    153,408 Most Valuable Professional on at

    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.

  • WarrenBelz Profile Picture
    153,408 Most Valuable Professional on at

    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 Profile Picture
    130 on at

    Thanks @WarrenBelz. It really helped.

     

  • cjbaguley Profile Picture
    35 on at
     
    With this solution below, how can I amend it to allow for non on the hour times? e.g. I only want the button available between 9:30am and 4pm?:
     
    If(
       Hour(Now()) >=8 && Hour(Now()) <=16 && 
       Weekday(Today()) >=2 && Weekday(Today()) <=6, 
       DisplayMode.Edit, 
       DisplayMode.Disabled
    )
  • WarrenBelz Profile Picture
    153,408 Most Valuable Professional on at
    Probably something like this
    With(
       {_Start: DateTimeValue(Text(Today(), "mm/dd/yyyy") & " 09:30:00")},
       If(
          Now() >= _Start && Hour(Now()) <=16 && 
          Weekday(Today()) >=2 && Weekday(Today()) <=6, 
          DisplayMode.Edit, 
          DisplayMode.Disabled
       )
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 386 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 321

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 311 Super User 2025 Season 2

Last 30 days Overall leaderboard