# SQL Query Issue

**URL:** <https://forum.inductiveautomation.com/t/sql-query-issue/10446>\
**Category:** Ignition\
**Created:** [September 9, 2015, 9:17pm UTC](https://forum.inductiveautomation.com/t/sql-query-issue/10446 "2015-09-09T21:17:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [September 9, 2015, 9:17pm UTC](https://forum.inductiveautomation.com/t/sql-query-issue/10446/1 "2015-09-09T21:17:55Z")

</div>

I am using the following SQL query to query data between a certain set of dates:

SELECT source, eventtime  
FROM alarm\_events  
WHERE eventtime BETWEEN Mon Jul 06 09:22:08 CDT 2015 and Mon Jul 06 09:22:18 CDT 2015

I keep getting an error and I know that it is in the third line. Is the date format going to present an issue between my SQL DB and my ignition platform? Or maybe a better question is what format should my date be in for this to work?

I would like to be able to tie the begin date and end date to a date selector on the screen that I am using, but am not sure it is possible considering the format differences between the two programs.

Thanks in advance for the help! 😃

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [September 9, 2015, 10:35pm UTC](https://forum.inductiveautomation.com/t/sql-query-issue/10446/2 "2015-09-09T22:35:25Z")

</div>

You can certainly reference a date range slider in your query. That would be the best thing to do anyhow. You don’t want the dates to be hard coded. You could have a query that resembles

`SELECT source, eventtime
FROM alarm_events
WHERE eventtime BETWEEN '{Root Container.Date Range.startDate}'
AND '{Root Container.Date Range.endDate}'`

Your query would probably work if you placed quotes around the dates. But making the date adjustable would be preferred in the end.

---

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [September 10, 2015, 12:09pm UTC](https://forum.inductiveautomation.com/t/sql-query-issue/10446/3 "2015-09-10T12:09:17Z")

</div>

Thanks Greg! I needed the quotation marks! I had tried indirect binding the first time, but did not use the quotation marks. That’s awesome! 😃😃😃
