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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Block days of the week...
Power Apps
Answered

Block days of the week on the calendar

(0) ShareShare
ReportReport
Posted on by 151

Hi guys!
In my app there users must select a certain date:

Guicord101_0-1648085577162.png

I would like two things:
I wish it wasn't possible to select days on Thursday and Friday, is that possible?
I would like it to only be possible to select a date 40 days after the current date, is that possible?

Categories:
I have the same question (0)
  • MF-12051538-0 Profile Picture
    402 on at

    Hi @Guicord101 ,

    There is no way of removing dates from the calendar control. One option would be to create a warning message to select a different date if the date selected is a Thursday, Friday, or less than 40 days in the future. 

    You can set the Visible property of your label (and/or icons) to this:

     

    With(
    {
    selectedWeekday: Weekday(DatePicker1.SelectedDate),
    selectedDate: DatePicker1.SelectedDate
    },
    selectedWeekday = 5 || selectedWeekday = 6 || selectedDate >= DateAdd(Today(), 40, Days)
    )

     

    If you found this post helpful, please consider Accepting it as the solution.

    Example.jpg
  • Guicord101 Profile Picture
    151 on at

    How do I create this notification message? I did not understand

  • MF-12051538-0 Profile Picture
    402 on at

    That notification message is just really an icon and a label in the app.

     

    Here are the steps: 

    1. Insert an icon (from the 'Insert' tab)
    2. Select the "Warning" icon, which is about 2/3 down the list
    3. Place the warning icon near your Date Picker
    4.  Insert a Label next to the warning icon
    5. For the text of this label, add the message you would like to display
    6. For both the label and the icon you just added, change the "Visible" function (from the dropdown in the top left) to this code (replace "DatePicker1" with the name of your Date Picker control):

        With(
    {
    selectedWeekday: Weekday(DatePicker1.SelectedDate),
    selectedDate: DatePicker1.SelectedDate
    },
    selectedWeekday = 5 || selectedWeekday = 6 || selectedDate >= DateAdd(Today(), 40, Days)
    )

     

    This icon and warning message will then only appear if somebody has selected an incorrect date.

     

     

  • Guicord101 Profile Picture
    151 on at

    It worked!!
    I would like to know if it is possible for me not to allow the person to submit the form if the selected date is on Thursday or Friday.
    If possible, I would like the message to appear notifying her when not submitting the form

  • MF-12051538-0 Profile Picture
    402 on at

    Absolutely. You can alter the same code and use that in the "Display Mode" function of your Submit button. Try this for Display Mode:

        With(
    {
    selectedWeekday: Weekday(DatePicker1.SelectedDate),
    selectedDate: DatePicker1.SelectedDate
    },
    If(
    selectedWeekday = 5 || selectedWeekday = 6 || selectedDate >= DateAdd(Today(), 40, Days),
    DisplayMode.Disabled,
    DisplayMode.Edit
    )
    )


    If you found this post helpful, please consider Accepting it as the solution.

  • Guicord101 Profile Picture
    151 on at

    This code worked when I select dates on Thursday and Friday. However, when I select dates 10 days later, the code does not work. I would like the warning to appear when the selected date is before 40 days after the current date
    In both cases this happens.

  • MF-12051538-0 Profile Picture
    402 on at

    Hi @Guicord101 ,

    That will just require a quick change from 'greater than or equal' to 'less than'. Adjusted code is below.

     

    For label warning:

     

    With(
    {
    selectedWeekday: Weekday(DatePicker1.SelectedDate),
    selectedDate: DatePicker1.SelectedDate
    },
    selectedWeekday = 5 || selectedWeekday = 6 || selectedDate < DateAdd(Today(), 40, Days)
    )

     

    For Submit button Display Mode:

     

     With(
    {
    selectedWeekday: Weekday(DatePicker1.SelectedDate),
    selectedDate: DatePicker1.SelectedDate
    },
    If(
    selectedWeekday = 5 || selectedWeekday = 6 || selectedDate < DateAdd(Today(), 40, Days),
    DisplayMode.Disabled,
    DisplayMode.Edit
    )
    )

     

    If you found this post helpful, please consider Accepting it as the solution.

  • Guicord101 Profile Picture
    151 on at

    It worked!!

    Guicord101_0-1648166155969.png

    However, as my "DefaultDate" is set to "Today()" the warning always appears. Do you know how to set "DefaultDate" to be a date in the future (example: 01/01/2999) or 40 days in the future?
    Thank you very much for your help. You are helping me to develop an application for over 7000 people.

  • Verified answer
    MF-12051538-0 Profile Picture
    402 on at

    You can use this as the Default Date:

    DateAdd(Today(), 40, Days)

     

    If you found this post helpful, please consider Accepting it as the solution.

  • Guicord101 Profile Picture
    151 on at

    THANKSS!!! YOU'RE AMAZING!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 633

#2
11manish Profile Picture

11manish 588

#3
Valantis Profile Picture

Valantis 457

Last 30 days Overall leaderboard