# Query help: passing dynamic date parameter

**URL:** <https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279>\
**Category:** Ignition\
**Created:** [March 16, 2022, 7:22pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279 "2022-03-16T19:22:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [March 16, 2022, 7:22pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/1 "2022-03-16T19:22:22Z")

</div>

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

can this be dynamic?  
Am I just doing it wrong?

---

<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:** [March 16, 2022, 7:25pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/2 "2022-03-16T19:25:03Z")

</div>

Are you using SQL syntax in the query parameters? I don’t think you can. You have to use [expression functions](https://docs.inductiveautomation.com/display/DOC81/Expression+Functions).

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [March 16, 2022, 7:34pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/3 "2022-03-16T19:34:57Z")

</div>

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

I am not seeing how to convert to datetime in the expression language  
[https://docs.inductiveautomation.com/display/DOC81/Date+and+Time](https://docs.inductiveautomation.com/display/DOC81/Date+and+Time)

I am trying dateFormat() with MM/d/YYYY now

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 16, 2022, 7:46pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/4 "2022-03-16T19:46:47Z")

</div>

Why use parameters? Can’t you do what you showed directly in the query?

---

<div class="post-metadata">

**Author:** ![Gaurav.Shitole](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gaurav.shitole/32/72050_2.png) [@Gaurav.Shitole](https://forum.inductiveautomation.com/u/Gaurav.Shitole)\
**Post date:** [March 16, 2022, 7:51pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/5 "2022-03-16T19:51:33Z")

</div>

Youu up will to do this in the query itself.

In your case it would be:

DATEADD(month, -5, :StartTime)

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [March 16, 2022, 8:01pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/6 "2022-03-16T20:01:48Z")

</div>

The screen shot looks like your trying to do that in the testing tab of a named query. I don’t think that was ever intended to work with anything other than an actual value. I’m not sure why your trying to be dynamic with it since that tab is just for testing. As soon as you close the named query, the value will clear out. It doesn’t save it as a default value. When you go to use a named query in your project, you will always need to provide it with those values. Depending on where you call it from you may be able to use an expression or a script function. If you don’t want to have to fill in variables when you go to run the query and your not looking to be able to change the dates in through another method, then you should hard code the DateTime items in your query.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [March 16, 2022, 8:06pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/7 "2022-03-16T20:06:46Z")

</div>

I wanted to send dynamic values from a dropdown

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [March 16, 2022, 8:09pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/8 "2022-03-16T20:09:29Z")

</div>

You can do that but that is setting up your expression on the your vision/perspective view instead of in the named query test screen.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [March 16, 2022, 8:09pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/9 "2022-03-16T20:09:52Z")

</div>

I wanted to test it though haha

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [March 16, 2022, 8:11pm UTC](https://forum.inductiveautomation.com/t/query-help-passing-dynamic-date-parameter/57279/10 "2022-03-16T20:11:57Z")

</div>

I’d just build a simple test screen and do it there. Depending on what I was putting on the screen I would probably set up custom properties on the drop down and do my expression right there then just bring the values into where your doing their query. Don’t know if your going to use it in a table or something else.
