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 Pages / DatePicker: disable th...
Power Pages
Answered

DatePicker: disable the past days

(0) ShareShare
ReportReport
Posted on by 45

Hi 🙂

I have a form that has a datepicker and a button for sending input and I would like my users to be able to choose only the current or future dates and not the past ones.

 

What I am doing and inform (visuall) the user that it is an invalid entry. For example, in the app shown below, when the date is selected, the border of the selector is changed and an error message is displayed:

 

DatePicker1.BorderColor: If(DatePicker1.SelectedDate<DateAdd(Today();-7;Days) || DatePicker1.SelectedDate>Today();Red;RGBA(67; 152; 209; 1))
Label1.Text: If(DatePicker1.SelectedDate<DateAdd(Today();-7;Days);"Maximum 2 days before today";DatePicker1.SelectedDate>Today();"Not after today";"")
Label1.Color: Red
Label1.Visible: DatePicker1.SelectedDate<DateAdd(Today();-7;Days) || DatePicker1.SelectedDate>Today()
Button.DisplayMode:If(DatePicker1.SelectedDate<DateAdd(Today();-7;Days) || DatePicker1.SelectedDate>Today();Disabled;Edit)

 All this works perfectly but it works alincontario.io I have to give the possibility to select 7 future not passed.

Thank you all for your help

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @bitvrbit :

    Based on your description, I understand that you are designing such a function:

    Case1: DateAdd(Today();-7;Days)<DatePicker1.SelectedDate<Today()

    • The DatePicker controls border will turn blue.

    Case2: DatePicker1.SelectedDate>Today()

    • The DatePicker controls border will turn red.
    • A label will turn on and show Not after today
    • The button will change to Disabledmode

    Case3: DateAdd(Today();-7;Days)>DatePicker1.SelectedDate

    • The DatePicker controls border will turn red.
    • A label will turn on and show Maximum 2 days before today
    • The button will change to Disabledmode

    I did a test, the above functions can be achieved very well.

    From your question, it seems that you want to add some functions. I am sorry that I dont quite understand what needs to be added.

    Could you describe it in detail?

    Best Regards,

    Bof

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
sannavajjala87 Profile Picture

sannavajjala87 38 Super User 2026 Season 1

#2
Valantis Profile Picture

Valantis 37

#3
Fubar Profile Picture

Fubar 23 Super User 2026 Season 1

Last 30 days Overall leaderboard