# Report with SQL Query Binding

**URL:** <https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024>\
**Category:** Ignition\
**Created:** [August 10, 2016, 9:35pm UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024 "2016-08-10T21:35:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jstwhln](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@jstwhln](https://forum.inductiveautomation.com/u/jstwhln)\
**Post date:** [August 10, 2016, 9:35pm UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024/1 "2016-08-10T21:35:07Z")

</div>

I’m trying to generate a report with the following SQL query where the report is on a window with two popup calendars.

`SELECT turbine_compliance.PowerOutput1,
  turbine_compliance.WindSpeed1,
  turbine_compliance.PowerOutput2,
  turbine_compliance.WindSpeed2,
  turbine_compliance.PowerOutput3,
  turbine_compliance.WindSpeed3,
  turbine_compliance.WindSpeed4,
  turbine_compliance.PowerOutput4,
  turbine_compliance.t_stamp
FROM turbine_compliance
WHERE   
t_stamp >= '{Root Container.StartDate}' AND
t_stamp <= '{Root Container.EndDate}'`

The problem I have is that I can get it to work using static dates, but I’m having trouble getting it to work with the dates generated by the popup calendars. I’ve tried using ‘{Root Container.Popup Calendar.date}’ and ‘{Root Container.Popup Calendar.formattedDate}’ in the WHERE clause. In the example above, I’m trying to reference the StartDate and EndDate properties from the report.

I’m at a loss, but being very new at SCADA programming, I know it’s just something simple that I’m missing.

I’m running 7.8.3 on Windows 7 x64

---

<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:** [August 10, 2016, 9:53pm UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024/2 "2016-08-10T21:53:00Z")

</div>

The report viewer component doesn’t run the report SQL. That happens in the gateway, not in the client, and can only reference report parameters. The report viewer will show bindable properties for each input parameter defined in the report, which is how you need to feed client-side data over to the report generator. Use start and end timestamp parameters in the report’s SQL. In the report viewer, bind those properties to the popup calendars to feed the desired dates/times to the report.

---

<div class="post-metadata">

**Author:** ![iheartada](https://avatars.discourse-cdn.com/v4/letter/i/6de8d8/32.png) [@iheartada](https://forum.inductiveautomation.com/u/iheartada)\
**Post date:** [August 10, 2016, 10:11pm UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024/3 "2016-08-10T22:11:49Z")

</div>

By report do you mean the results of a query or report from the report module? If you want the user to be able to select two dates and view the results in a table then all you have to do is select the chain icon and find the date value from each calendar. You can script it to export the data to a html file, and then have the file open in a browser. Somewhere in the docs it should tell you how to do it.

---

<div class="post-metadata">

**Author:** ![jstwhln](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@jstwhln](https://forum.inductiveautomation.com/u/jstwhln)\
**Post date:** [August 10, 2016, 10:26pm UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024/4 "2016-08-10T22:26:49Z")

</div>

> [@pturmel](#):
>
> The report viewer component doesn't run the report SQL. That happens in the gateway, not in the client, and can only reference report parameters. The report viewer will show bindable properties for each input parameter defined in the report, which is how you need to feed client-side data over to the report generator. Use start and end timestamp parameters in the report's SQL. In the report viewer, bind those properties to the popup calendars to feed the desired dates/times to the report.

Ok, thanks for the clarification.

This is what I've been using as a reference: [https://docs.inductiveautomation.com:8443/display/DOC/SQL+Query+Binding](https://docs.inductiveautomation.com:8443/display/DOC/SQL+Query+Binding)

---

<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:** [August 10, 2016, 11:37pm UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024/5 "2016-08-10T23:37:59Z")

</div>

[quote=“jstwhln”]This is what I’ve been using as a reference: [https://docs.inductiveautomation.com:8443/display/DOC/SQL+Query+Binding](https://docs.inductiveautomation.com:8443/display/DOC/SQL+Query+Binding)[/quote]Right. That’s how you supply query data to client-side objects other than the reporting module.

---

<div class="post-metadata">

**Author:** ![jstwhln](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@jstwhln](https://forum.inductiveautomation.com/u/jstwhln)\
**Post date:** [August 11, 2016, 3:04am UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024/6 "2016-08-11T03:04:25Z")

</div>

Got it, thanks!

---

<div class="post-metadata">

**Author:** ![jstwhln](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@jstwhln](https://forum.inductiveautomation.com/u/jstwhln)\
**Post date:** [August 17, 2016, 7:32pm UTC](https://forum.inductiveautomation.com/t/report-with-sql-query-binding/12024/7 "2016-08-17T19:32:53Z")

</div>

Using ? in the WHERE clause solved my problem. It let me supply query data to the gateway.
