cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kavitaparab
Level: Powered On

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

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

 

kavitaparab
Level: Powered On

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

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

kavitaparab
Level: Powered On

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

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,794)