# Set Date Picker Value from View Parameter

**URL:** <https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697>\
**Category:** Ignition\
**Created:** [April 21, 2022, 2:52pm UTC](https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697 "2022-04-21T14:52:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gfeiten](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@gfeiten](https://forum.inductiveautomation.com/u/gfeiten)\
**Post date:** [April 21, 2022, 2:52pm UTC](https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697/1 "2022-04-21T14:52:31Z")

</div>

1. I am trying to pass an initial value for a DateTimePicker as a parameter to a popup window. The date parameter is obtained from a SQL query.

2. I bound a label in the pop up window to the date parameter and that works fine. It is formatted as: May 1, 2022, 6:00:37 PM

3. The DateTimePicker components value is bound to the date parameter (Expression {view.params.commit\_date} )This is not working (the component displays the current date/time)

4. I have a button that writes the DateTimePicker value to the SQL table queried in (1). This works fine. So in step 1 I am reading the data written to SQL by the button script (the DateTimePicker value)

5. I noticed that when I write picker value to the view date parameter in the same script (4) the format is changed to: “2022-05-01T22:00:37.510Z”

So I am theorizing that in step 1 I need to reformat the date parameter? From the testing I have done everything is type java.util.Date, so there  
shouldn’t be a conflict there.

Ignition documentation states the value property is value:dropdown. Do I need to reformat the datetime for that???

Ignition version is 8.06

Thanks!!!

---

<div class="post-metadata">

**Author:** ![gfeiten](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@gfeiten](https://forum.inductiveautomation.com/u/gfeiten)\
**Post date:** [April 22, 2022, 1:34pm UTC](https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697/2 "2022-04-22T13:34:58Z")

</div>

It looks like this is an issue with passing the date to a view parameter and binding the component to the parameter.

It works fine when I changed the button script to write the date to a tag before opening the popup, and binding the component to the tag.

I don’t really like this approach as multiple people could be performing updates at the same time overwriting the date field.

---

<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:** [April 22, 2022, 2:02pm UTC](https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697/3 "2022-04-22T14:02:04Z")

</div>

Don’t write it to a tag. Make a bidirectonal binding to a sesson variable. That way it will only affect the one client.

- On the Project Browser select _Perspective_.
- In the Property Editor go down to the Session Custom section and add a custom property. Call it `selectedDate` or whatever you like.
- Bind the DateTimePicker value to the custom session variable. Make sure it’s bidirectional.
- Bind everything that needs it to the session variable.

This is a handy way to, for example, put the date picker in the page banner and have it useable by all the views.

---

<div class="post-metadata">

**Author:** ![gfeiten](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@gfeiten](https://forum.inductiveautomation.com/u/gfeiten)\
**Post date:** [April 22, 2022, 2:37pm UTC](https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697/4 "2022-04-22T14:37:58Z")

</div>

Thanks! I was thinking there must be some functionality like this.

I solved my issue by binding the date picker to a query (instead of running the query on the button action and passing the result as a parameter). The advantage to my first approach is I could pull values for multiple components with one query and pass them as parameters. Now I am binding each component to it’s own query.

I want to try your idea, it seems much cleaner.

---

<div class="post-metadata">

**Author:** ![Henrique\_Trebilcock](https://avatars.discourse-cdn.com/v4/letter/h/8edcca/32.png) [@Henrique\_Trebilcock](https://forum.inductiveautomation.com/u/Henrique_Trebilcock)\
**Post date:** [August 9, 2024, 11:39am UTC](https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697/5 "2024-08-09T11:39:43Z")

</div>

I had some problem, I was trying to write in the value a string. I had to use system.date.parse(selected\_data["start"], "yyyy-MM-dd HH:mm:ss") to convert from String to DateTime format.

---

<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 9, 2024, 12:54pm UTC](https://forum.inductiveautomation.com/t/set-date-picker-value-from-view-parameter/58697/6 "2024-08-09T12:54:10Z")

</div>

> [@Henrique\_Trebilcock](#):
>
> I was trying to write in the value a string.

You should always use datetime datatypes within the application until you need to convert it to human-readable format.
