# Named Queries with start date and end date question

**URL:** <https://forum.inductiveautomation.com/t/named-queries-with-start-date-and-end-date-question/34300>\
**Category:** Ignition\
**Created:** [April 29, 2020, 12:39pm UTC](https://forum.inductiveautomation.com/t/named-queries-with-start-date-and-end-date-question/34300 "2020-04-29T12:39:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgonya](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgonya/32/9304_2.png) [@jgonya](https://forum.inductiveautomation.com/u/jgonya)\
**Post date:** [April 29, 2020, 12:39pm UTC](https://forum.inductiveautomation.com/t/named-queries-with-start-date-and-end-date-question/34300/1 "2020-04-29T12:39:33Z")

</div>

Is there a way to used named queries with a start and end date. Something like this?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/714bba144383ede5f4ec4b891d8562137e69d8a5.png)  
I think i have and error in the queries.

If there is a way to do that. Can there be a way to use the named query can be used as a data Sources in a report using the Parameters?  
Something like this:

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

I think I’m doing something wrong here but let me know if I can even do this?

---

<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:** [April 29, 2020, 12:44pm UTC](https://forum.inductiveautomation.com/t/named-queries-with-start-date-and-end-date-question/34300/2 "2020-04-29T12:44:49Z")

</div>

Looks fine as far as the parameters go. Most SQL DB’s I’m familiar with will fail if the WHERE clause is after the ORDER BY clause. The error you are getting probably says so. (Show the error next time so we don’t have to guess.)

---

<div class="post-metadata">

**Author:** ![jgonya](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgonya/32/9304_2.png) [@jgonya](https://forum.inductiveautomation.com/u/jgonya)\
**Post date:** [April 29, 2020, 12:53pm UTC](https://forum.inductiveautomation.com/t/named-queries-with-start-date-and-end-date-question/34300/3 "2020-04-29T12:53:09Z")

</div>

I fixed the query:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/8a881e404d874329578303c1df14cff132c8081d.png)  
(I saw there WHERE as I posted it)

Here is the error:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/1d889cae7a57828163dbd6bbf032042c59dbbe72.png)

---

<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:** [April 29, 2020, 12:57pm UTC](https://forum.inductiveautomation.com/t/named-queries-with-start-date-and-end-date-question/34300/4 "2020-04-29T12:57:18Z")

</div>

Moved the where clause too far up. DB’s don’t like them before the FROM clause, either. Consider looking at the manual of your DB for the strict syntax diagram for SELECT queries. (As suggested by the error message, too.)

---

<div class="post-metadata">

**Author:** ![jgonya](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgonya/32/9304_2.png) [@jgonya](https://forum.inductiveautomation.com/u/jgonya)\
**Post date:** [April 29, 2020, 1:03pm UTC](https://forum.inductiveautomation.com/t/named-queries-with-start-date-and-end-date-question/34300/5 "2020-04-29T13:03:30Z")

</div>

Thanks, Not getting the error anymore just not getting data, That might be user error.
