# Date Range component - lock outer range dates

**URL:** <https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [June 21, 2017, 8:57pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578 "2017-06-21T20:57:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kcabatic](https://avatars.discourse-cdn.com/v4/letter/k/b19c9b/32.png) [@kcabatic](https://forum.inductiveautomation.com/u/kcabatic)\
**Post date:** [June 21, 2017, 8:57pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578/1 "2017-06-21T20:57:18Z")

</div>

Hi,

Is it possible to lock the outer range dates for the date range/easy chart component so user cannot go outside of set date range?

We want to limit what data user has access to. For example if they view data by ID number we want to lock the date range to specific date and times.

Ken

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [June 22, 2017, 4:13pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578/2 "2017-06-22T16:13:57Z")

</div>

I don’t think there is a built in function for this. What I’ve done in the past is set up a property change script on the date selector, such that , if one of the dates goes outside the limits, set that date equal to the respective limit… In my experience, this is an effective solution.

---

<div class="post-metadata">

**Author:** ![kcabatic](https://avatars.discourse-cdn.com/v4/letter/k/b19c9b/32.png) [@kcabatic](https://forum.inductiveautomation.com/u/kcabatic)\
**Post date:** [June 22, 2017, 7:04pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578/3 "2017-06-22T19:04:55Z")

</div>

Appreciate the reply

I figured as much and that was one of the ideas that was floating around.

Thanks

---

<div class="post-metadata">

**Author:** ![DwSoFt](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@DwSoFt](https://forum.inductiveautomation.com/u/DwSoFt)\
**Post date:** [May 17, 2018, 3:09pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578/4 "2018-05-17T15:09:09Z")

</div>

Can i have an example of this? my tag tag seems to always get hung up by java.util.date and im not sure why

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [May 24, 2018, 6:36pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578/5 "2018-05-24T18:36:11Z")

</div>

Hi DwSoFt,

Sorry for the late reply. Here is a basic example for a script that would go into Property Change Scripts on a Date Range component:

```auto
if event.propertyName == "startDate":
	if event.source.startDate < system.date.getDate(2018, 00, 01):
		event.source.startDate = system.date.getDate(2018, 00, 01)
if event.propertyName == "endDate":
	if event.source.endDate > system.date.now():
		event.source.endDate = system.date.now()
```

Not sure if you were doing it, but in general I avoid using java.util.stuff, and try to stick to the ignition equivalents if possible… so system.date rather than java.util.date.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2018, 6:47pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578/6 "2018-05-24T18:47:55Z")

</div>

> [@zacslade](#):
>
> Not sure if you were doing it, but in general I avoid using java.util.stuff, and try to stick to the ignition equivalents if possible.. so system.date rather than java.util.date.

FWIW, I always do exactly the opposite. The java.util.Date and java.util.Calendar stuff have been there since the beginning of Ignition and always work. You never know when you'll want to cut and paste into an older install.

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [May 24, 2018, 7:16pm UTC](https://forum.inductiveautomation.com/t/date-range-component-lock-outer-range-dates/14578/7 "2018-05-24T19:16:45Z")

</div>

Interesting pturmel, I hadn’t thought of it that way, but that makes sense. Maybe I’ll expand my scripting vocabulary a little in future projects.
