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

 

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 Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,909)