cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User
Super User

Re: Lock date range for selection

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
Highlighted
Super User
Super User

Re: Lock date range for selection

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

 

Highlighted
Frequent Visitor

Re: Lock date range for selection

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

Highlighted
Super User
Super User

Re: Lock date range for selection

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

Highlighted
Frequent Visitor

Re: Lock date range for selection

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

Highlighted
Helper I
Helper I

Re: Lock date range for selection

HelloThéo.

Highlighted
Helper I
Helper I

Re: Lock date range for selection

HelloThéo.

Highlighted
Helper I
Helper I

Re: Lock date range for selection

 

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
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,310)