cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alfie_Smith
Helper I
Helper I

Trying to limit access to button by date - formula isn't working as intended

 

If(Text(Today(), "[$-en-US]ddd", "en-GB") = "Monday" Or "Thursday" 
And Text(CCDatePicker.SelectedDate,"[$-en-US]mm/dd/yyyy") = Text(DateAdd(Today(),1),"[$-en-US]dd/mm/yyyy")  
And Value(Hour(Now())) > 10, 
View, Edit)

 

I am trying to do the following:

 

If today is either Monday or Thursday,

Check if date selected by user is equal to tomorrow 

and that if the time is past 10am.

 

Not working, not sure why. Can anyone shine some light on this for me?

Thanks in advance 🙂 

2 ACCEPTED SOLUTIONS

Accepted Solutions
eka24
Super User
Super User

Use this formula:

Weekday(Today())=2 Or Weekday(Today())=5 &&
DatePicker2_1.SelectedDate=Today()+1&&Hour(Now())>10
It based on the assumption that starting day of the week is sunday=1
 
If you like this post, give a Thumbs up. Where it solved your request,
Mark it as a Solution to enable other users find it.
 

View solution in original post

v-xida-msft
Community Support
Community Support

Hi @Alfie_Smith ,

Based on the formula that you provided, I think there is something wrong with it.

 

The Text(datetimevalue, "[$-en-US]ddd") formula would display the day as an abbreviation (Sun to Sat) rather than (Sunday to Saturday). On your side, you should change it as below:

Text(datetimevalue, "[$-en-US] dddd", "en-GB")

Date and time placeholders in Text function

 

In addition, when comparing if selected date value is equal to tomorrow, please make sure the custom date time format (e.g. "mm/dd/yyyy") you specified within the Text function is the same.

 

I have made a test on my side, please consider modify your whole formula as below (set the DisplayMode property of the button to following😞

If(
   (Text(datetimevalue, "[$-en-US] dddd", "en-GB") = "Monday" || Text(datetimevalue, "[$-en-US] dddd", "en-GB") = "Thursday") && Text(CCDatePicker.SelectedDate, "[$-en-US] mm/dd/yyyy") = Text(Today()+1,"[$-en-US]mm/dd/yyyy") && Hour(Now()) > 10,
   DisplayMode.View,
   DisplayMode.Edit
)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
eka24
Super User
Super User

Use this formula:

Weekday(Today())=2 Or Weekday(Today())=5 &&
DatePicker2_1.SelectedDate=Today()+1&&Hour(Now())>10
It based on the assumption that starting day of the week is sunday=1
 
If you like this post, give a Thumbs up. Where it solved your request,
Mark it as a Solution to enable other users find it.
 

View solution in original post

v-xida-msft
Community Support
Community Support

Hi @Alfie_Smith ,

Based on the formula that you provided, I think there is something wrong with it.

 

The Text(datetimevalue, "[$-en-US]ddd") formula would display the day as an abbreviation (Sun to Sat) rather than (Sunday to Saturday). On your side, you should change it as below:

Text(datetimevalue, "[$-en-US] dddd", "en-GB")

Date and time placeholders in Text function

 

In addition, when comparing if selected date value is equal to tomorrow, please make sure the custom date time format (e.g. "mm/dd/yyyy") you specified within the Text function is the same.

 

I have made a test on my side, please consider modify your whole formula as below (set the DisplayMode property of the button to following😞

If(
   (Text(datetimevalue, "[$-en-US] dddd", "en-GB") = "Monday" || Text(datetimevalue, "[$-en-US] dddd", "en-GB") = "Thursday") && Text(CCDatePicker.SelectedDate, "[$-en-US] mm/dd/yyyy") = Text(Today()+1,"[$-en-US]mm/dd/yyyy") && Hour(Now()) > 10,
   DisplayMode.View,
   DisplayMode.Edit
)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@Alfie_Smith 

Yesterday you marked my reply as a solution, is there any issue with the formula?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,883)