# Unable to select the current date from date time picker in perspective irrespective of setting the max date as today's date. It allows to select today's date but when selected set -1 date for the value

**URL:** <https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 1, 2022, 12:52pm UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542 "2022-08-01T12:52:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khushboo\_Amarnani](https://avatars.discourse-cdn.com/v4/letter/k/b19c9b/32.png) [@Khushboo\_Amarnani](https://forum.inductiveautomation.com/u/Khushboo_Amarnani)\
**Post date:** [August 1, 2022, 12:52pm UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/1 "2022-08-01T12:52:29Z")

</div>

![max date binding](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/2/d2c08e6b7669fd0367775b47a5546366d014dff0.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 1, 2022, 1:08pm UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/2 "2022-08-01T13:08:57Z")

</div>

Welcome to the forum.

1. Your `now()` function seems to be working in the binding preview but I can only see `8-1 7:45:22` in the maxDate binding. Is the year in there as well?
2. I don’t see the `-1` in `props.value`. Where are you seeing it?
3. There is an error message on the PROPS bar. Hover over the ‘1’ and it will give you some details.

Tips:

1. Your question title should be a summary about the question. The details should be in the body of the post.
2. `now()` will update continuously. Every minute would probably be enough so you could use `now(60000)`.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 1, 2022, 1:39pm UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/3 "2022-08-01T13:39:33Z")

</div>

What version are you using?  
What is `maxDate` bound to?  
What is `value` bound to?  
Why are you binding the `value` of the input? Doing so with a “polling” binding like the `now()` expression will eventually overwrite anything a user would select, ie: after a user makes their selection, the expression will re-evaluate and replace their selection with a new value.  
If you hover over the warning, what does it tell you?

---

<div class="post-metadata">

**Author:** ![Khushboo\_Amarnani](https://avatars.discourse-cdn.com/v4/letter/k/b19c9b/32.png) [@Khushboo\_Amarnani](https://forum.inductiveautomation.com/u/Khushboo_Amarnani)\
**Post date:** [August 1, 2022, 2:26pm UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/4 "2022-08-01T14:26:37Z")

</div>

Version - 8.1.14  
maxDate is bound to expression : now() as shown in snapshot  
I’m binding the value of input to view param for the value, as I’m using a rendered view for datetime component to be used in table component.  
Attaching the warning image.  
 ![warning hover](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/5/a5031cbde0d828b586cd8d2ff6fd4d42efbfa200.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 1, 2022, 2:33pm UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/5 "2022-08-01T14:33:39Z")

</div>

If you have the value bound to a view parameter then how will the user be able to change the date?  
Do you want to load the view with a particular date and then allow the user to select a different one? If that date is today then it’s easy - just use `now(0)` which wll run once on loading the view.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 1, 2022, 3:27pm UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/6 "2022-08-01T15:27:20Z")

</div>

Okay, so the problem you’re encountering here is pretty clearly described by the warning message: the `value` prop is expecting either `null`, a number (unix timestamp) or a date object - but the view param you’ve bound against contains a string (or an empty string).

But the larger problem is that you should never bind the “value” of an input component when that component will be used by an end-user because of the nature of bindings; you never know when they will evaluate and replace the user’s value. For example, if you bind against a View param, and then the user selects a date, and then the page is refreshed for any reason, then the selected value will be the View param instead of the value selected by the user.

---

<div class="post-metadata">

**Author:** ![Khushboo\_Amarnani](https://avatars.discourse-cdn.com/v4/letter/k/b19c9b/32.png) [@Khushboo\_Amarnani](https://forum.inductiveautomation.com/u/Khushboo_Amarnani)\
**Post date:** [August 2, 2022, 6:06am UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/7 "2022-08-02T06:06:36Z")

</div>

Even if I use the date time picker component separately, without binding the value the date I select from the picker for the first time is taken a -1 date. But it takes the same date as selected for the second time. Can you please explain why does this happen so?

---

<div class="post-metadata">

**Author:** ![Khushboo\_Amarnani](https://avatars.discourse-cdn.com/v4/letter/k/b19c9b/32.png) [@Khushboo\_Amarnani](https://forum.inductiveautomation.com/u/Khushboo_Amarnani)\
**Post date:** [August 2, 2022, 7:49am UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/8 "2022-08-02T07:49:13Z")

</div>

In addition to this, if I bind maxDate to now() I cannot select today’s date also. Be it first time or second time, it always takes -1 date.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 2, 2022, 11:28am UTC](https://forum.inductiveautomation.com/t/unable-to-select-the-current-date-from-date-time-picker-in-perspective-irrespective-of-setting-the-max-date-as-todays-date-it-allows-to-select-todays-date-but-when-selected-set-1-date-for-the-value/62542/9 "2022-08-02T11:28:12Z")

</div>

I don’t know what “-1 date” is. Could you explain what that means in this context?  
I suspect you’r trying to convey that you can only select up to the current day - 1 day. This is most likely because of the hour that is selected when you select a day.

Suppose I use the `now()` expression for my `maxDate` prop and the current time (ON THE GATEWAY) is `2022-8-2 11:23:06`. I then attempt to select August 2nd 2022 in the DateTime Picker (or input), but this fails. If you remove the binding for `maxDate` and reset it to `null`, and _then_ try to select the same date again, you’ll see that the selected date has a value of `2022-8-2 12:00:00`. Well, that `12:00:00` value is greater than `11:23:06`, so it won’t let you select it.
