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

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

 

Highlighted

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

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

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

HelloThéo.

Highlighted

HelloThéo.

Highlighted

 

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (13,396)