Perspective: restrict DateTime input till current date only

Hi

Is there a way to restrict the date choices in DateTime input component in perspective to not allow to select future dates, only dates till the current date should be allowed to select on the calendar and the future dates should be grayed-out/disabled.

Thanks
Yash Bhan

I put this in a change script on the value property of the DateTimePicker. It doesn’t gray out future dates, but it does disallow choosing dates in the future. You can tweak it to behave exactly how you want it to.

now = system.date.now()
	if system.date.isAfter(currentValue.value,now) and origin!='Script':
		try:
			if system.date.isAfter(previousValue.value,now):
				self.props.value = now
			else:
				self.props.value = previousValue.value
		except AttributeError:
			self.props.value = now
1 Like

Both Date Picker components have a minDate and a maxDate property to define available dates for the picker. It doesn’t truly “gray-out” the unavailable dates, but it does prevent them from being selected and it applies a “restricted” cursor when hovering over restricted dates. Months and years in the dropdown ARE grayed-out.


This feature was only introduced fairly recently (8.0.13).

1 Like

Thanks a lot! Will try this

Ahaa, we are on 8.0.12, hence I couldn’t see the option. Thanks for the info!

1 Like