cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
luisabsg
Helper V
Helper V

Disable days in datapicker

Hello, how r u?

I'm using this condition in the border color of date picker:

If(Weekday(DataCardValueDate.SelectedDate)=4, Red, Parent.BorderColor)

The red border appears when a day other than Wednesday is selected. But I only need the first 3 Wednesdays of the month. How can I add this border for the other Wednesdays as well?

 

example:

3 aug

10 aug

17 aug 

is ok

 

24 aug

31 aug 

appears the red border

 

luisabsg_0-1662118060655.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Roverandom
Solution Supplier
Solution Supplier

Yes.. I realized this after I answered you. But this one works better:

 

If(
    And(
        Month(Self.SelectedDate) = Month(Self.SelectedDate),
        Day(Self.SelectedDate) > 20
    ),
    Color.Red,
    If(
        Weekday(Self.SelectedDate, StartOfWeek.Monday) <> 3,
        Color.Red,
        Color.Gray
    )
)

 

It's not the best but it works...



Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.

View solution in original post

9 REPLIES 9
Nogueira1306
Super User
Super User

Hello!

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/disable-few-days-in-DatePicker-control-based...

 

Something like that should work...

First off all, I think that you should check if it is a Wednesday or not, using WeekDay function.

 

If it is WeekDay = 4, it is a wednesday.

 

https://docs.microsoft.com/en-us/power-platform/power-fx/reference/function-datetime-parts

 

After thath, you need to check if it is the last Wednesday or not..

The only way that I am remembering is doing something like this:

 1. Add 7 days to your day

 2. Check if it is the same month

 3. if it is, it is the last wednesday of the month

 

Overall

 

If(WeekDay(DatePicker.Selected.Date) = 4;

   Notify("It is Wednesday");;

   Set(varDate;DateAdd(DatePicker.Selected.Date,7,Days));;

    If(Month(DatePicker.Selected.Date) = Month(varDate);

       Notify("Not the last wednesday") //SHOW ERROR AND DO NOT LET THE USER SUBMIT FORM

    )

    Notify("Not Wednesday") //SHOW ERROR AND DO NOT LET THE USER SUBMIT FORM

)

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,

Gonçalo Nogueira

Check my LinkedIn!

My website!

Roverandom
Solution Supplier
Solution Supplier

If(
    Weekday(
        Self.SelectedDate,
        StartOfWeek.Monday
    ) <> 3,
    Color.Red,
    Color.Gray
)


Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.

This condition does the same to mine. I need that, in addition, I can only select the first 3 wednesdays of the month

Ty for asking but didn't work 😞

Roverandom
Solution Supplier
Solution Supplier

Try this:

 

If(
    And(
        Month(Self.SelectedDate) = Month(Self.SelectedDate),
        Day(Self.SelectedDate) > 20
    ),
    Color.Red,
    Color.Gray
)


Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.
Roverandom
Solution Supplier
Solution Supplier

Try this:

 

 

If(
    And(
        Month(Self.SelectedDate) = Month(Self.SelectedDate),
        Day(Self.SelectedDate) > 20
    ),
    Color.Red,
    Color.Gray
)

 

Edit: Greater than 20 so that only the first two weeks are valid...

 



Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.

It works, but it works for all dates

eg:

 

luisabsg_1-1662122188906.png

 

 

Roverandom
Solution Supplier
Solution Supplier

Yes.. I realized this after I answered you. But this one works better:

 

If(
    And(
        Month(Self.SelectedDate) = Month(Self.SelectedDate),
        Day(Self.SelectedDate) > 20
    ),
    Color.Red,
    If(
        Weekday(Self.SelectedDate, StartOfWeek.Monday) <> 3,
        Color.Red,
        Color.Gray
    )
)

 

It's not the best but it works...



Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.

thank you 🙂

Helpful resources

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

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