# Named Query binded to datetime picker

**URL:** <https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 29, 2024, 1:50pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071 "2024-05-29T13:50:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 29, 2024, 1:50pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/1 "2024-05-29T13:50:31Z")

</div>

Hello!

I have a Named query in a table binded to a datetime picker value.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/25c6373825aea33696f172e5f63a2af8a01bdbaf.png)

```python
SELECT 
 ..

    AND WO.WORKORDERDATE BETWEEN :StartDate AND :EndDate
GROUP BY 
    WO.WORKORDERDATE, 

...

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/a/8a495c16001dbe0abaf4dca3a4f51c2bef8eaa94.png)

The data time pickers has fixed values so there is something in the table when it loads.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/a/aa8fc3ffad0384b658acdd91fe90a80b22ddbc72.png)

It loads the data well but when I change the time on the datetime pickers doesn´t reload the specify Named Query.

Any idea how to make it work?

---

<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:** [May 29, 2024, 1:59pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/2 "2024-05-29T13:59:44Z")

</div>

Those DateTime pickers seem to be inside flex containers. If that is so, it means that `{../DateTimePicker_Start.props.value}` can't be the correct path and the query should give an error.

You can start using parent.parent.getSibling.getChild.getUncle or, much better, create custom properties on the view, `custom.dateTimePicker_start` and `custom.dateTimePicker_End`.

- Bind each datepicker to the view custom property. Make the binding bidirectional.
- Edit the query binding to look at the custom properties. It will be simply `view.custom.dateTimePicker_Start`, etc.

---

<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:** [May 29, 2024, 2:01pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/3 "2024-05-29T14:01:14Z")

</div>

You have scrollbars on the datepicker containers. You probably need to set `height : auto`.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 29, 2024, 2:16pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/4 "2024-05-29T14:16:24Z")

</div>

Great, thanks, now it works,

I adapt what you said, I added a custom property as bidirectional bind to the datepicker value.  
I didn´t realize about the bidirectional binding at all.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/5/35db24712200c91e12b2eb974d6c67214f5fc86d.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/f/0ff429180f4af6336ac8a231a3456347718ac88c.png)

The only issue is when the page loads the datepicker shows current date

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/a/fac0536efb7a9962ed3e7aeee4c7db0ca11246d3.png)

instead the date by default  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6b793bf4c79159d01caae25f15e2212cc4d8a12.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:** [May 29, 2024, 2:20pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/5 "2024-05-29T14:20:25Z")

</div>

You have created `custom.date` on the datepicker. That doesn't help you. I recommend that you **create it on the view**.

Then, on `view.custom.date` create an expression binding:  
`now(0)`

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 29, 2024, 3:44pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/6 "2024-05-29T15:44:25Z")

</div>

Thanks Transistor, I aplied your fix

Now I have 2 custom properties on my view so the datapicker show this values  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/76ebd33ef12d58971b704704d260f0bc8085f6bd.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d691afab50a4c65ef5d2fbe6e7c30db553257a47.png)

I aplied the expression binding  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/8/c8bb81a3eec5801a5a548a698c986880c77dd54a.png)

Once the date format appear on the custom property I deleted the binding so I can put any date I need.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/7/a72080f10ac62c31ec274e83d33c359e1d1b1f18.png)

Cheers!

---

<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:** [May 29, 2024, 3:56pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/7 "2024-05-29T15:56:38Z")

</div>

`now(0)` runs only once when the view is loaded. You can leave it there so that it gets today as start value every time.

```python
now() <-- executes at default scan rate.
now(0) <-- executes once.
now(123) <-- executes every 123 ms.

```

* * *

Tip:  
 ![Binding title bar](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/5/b58c139c60493ed8300dc94003d87e3b6a02a5f1.png)

When showing screengrabs of the binding dialog, always show the title bar so that we can see what component the binding is on.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 29, 2024, 3:59pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/8 "2024-05-29T15:59:52Z")

</div>

Thanks,

The thing is the table is part of a report tool and the StartDate should be at least one year ago

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/d/fda4b9cf3ed1c6bbf3dce1e41c7a18214865b87b.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:** [May 29, 2024, 4:20pm UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/9 "2024-05-29T16:20:40Z")

</div>

`midnight(addYears(now(0), -1))` will return one year ago at 00:00:00.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 30, 2024, 6:33am UTC](https://forum.inductiveautomation.com/t/named-query-binded-to-datetime-picker/91071/10 "2024-05-30T06:33:10Z")

</div>

Ok, great!, thanks

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/185b03a36770d1ed5fc37da3314952a1c39b4525.png)
