cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kavitaparab
Frequent Visitor

Lock date range for selection

Hi,

 

I have created a timesheet app connected to a Sharepoint list. Here I would like to restrict the user to fill timesheet only for specific period ie. only for the past week for eg. Till this week tuesday, I want them to fill timesheet only from last week Monday to Sunday. All previous days selection should be disabled. I read through the information available on net but couldn't identify which formula will work.

 

Any help on this will be really helpful.

 

Regards,

Kavita

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @kavitaparab

 

As I said, no way to disable some date in a DatePicker. That's means that if you want to let your users select a date, they'll be able to select whatever date they want within the calendar. 

What you can do is showing to your users (by visual effects and text display) that the selected date doesn't fit in the allowed range, and disable the ability to move forward until his date selection match the allowed range.

 

Screenshot_20180918-192503~2.pngScreenshot_20180918-192409~2.pngScreenshot_20180918-192434~2.png

 

 

DatePicker.BorderColor : 
If(DatePicker1.SelectedDate<DateAdd(Today(),-7,Days) || DatePicker1.SelectedDate>Today(),Red,Blue)

 

ErrorLabel.Text : 

If(DatePicker1.SelectedDate<DateAdd(Today(),-7,Days),"Maximum 7 days before today",DatePicker1.SelectedDate>Today(),"Not after today","")

ErrorLabel.Color :

Red

ErrorLabel.Visible : 

DatePicker1.SelectedDate<DateAdd(Today(),-7,Days) || DatePicker1.SelectedDate>Today()

 

Button.DisplayMode : 

If(DatePicker1.SelectedDate<DateAdd(Today(),-7,Days) || DatePicker1.SelectedDate>Today(),Disabled,Edit)

 

Théo

 

View solution in original post

7 REPLIES 7
tchin-nin
Memorable Member
Memorable Member

Hi,

There is no way at the moment to prevent specific date selection in the DatePicker control. 

 

The only way in my opinion to get close to what you want is to add a label to warn the user his date selection is not in the allowed ranged. 

 

Théo

 

Theo, thank you for your reply, will try label as an option.

 

Is there a possibility to set today -7 as a formula for date picker where a user will not be able to select the date for more than previous 7 days?

 

Regards,

Kavita

Hi @kavitaparab

 

As I said, no way to disable some date in a DatePicker. That's means that if you want to let your users select a date, they'll be able to select whatever date they want within the calendar. 

What you can do is showing to your users (by visual effects and text display) that the selected date doesn't fit in the allowed range, and disable the ability to move forward until his date selection match the allowed range.

 

Screenshot_20180918-192503~2.pngScreenshot_20180918-192409~2.pngScreenshot_20180918-192434~2.png

 

 

DatePicker.BorderColor : 
If(DatePicker1.SelectedDate<DateAdd(Today(),-7,Days) || DatePicker1.SelectedDate>Today(),Red,Blue)

 

ErrorLabel.Text : 

If(DatePicker1.SelectedDate<DateAdd(Today(),-7,Days),"Maximum 7 days before today",DatePicker1.SelectedDate>Today(),"Not after today","")

ErrorLabel.Color :

Red

ErrorLabel.Visible : 

DatePicker1.SelectedDate<DateAdd(Today(),-7,Days) || DatePicker1.SelectedDate>Today()

 

Button.DisplayMode : 

If(DatePicker1.SelectedDate<DateAdd(Today(),-7,Days) || DatePicker1.SelectedDate>Today(),Disabled,Edit)

 

Théo

 

View solution in original post

Thank you so much for your reply. Right now for the timesheet application we have changed the rules, but will definitely try this for other application.

 

Regards,

Kavita

HelloThéo.

HelloThéo.

 

I tried your example and it works perfectly :).
I would like to use your example but get the opposite result from the previous days.
logically I changed the value days + 7 or only 7. But I get an error. where am i wrong? Can I get a push from you in the right direction?
Hello and thanks
Simone

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,964)