# Pulling date range out of report table

**URL:** <https://forum.inductiveautomation.com/t/pulling-date-range-out-of-report-table/19791>\
**Category:** Ignition\
**Created:** [September 24, 2018, 7:48pm UTC](https://forum.inductiveautomation.com/t/pulling-date-range-out-of-report-table/19791 "2018-09-24T19:48:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [September 24, 2018, 7:48pm UTC](https://forum.inductiveautomation.com/t/pulling-date-range-out-of-report-table/19791/1 "2018-09-24T19:48:35Z")

</div>

Here is my code. Parameter TimeHolder is set to now(). I get an error: **WARN: Simple Query could not be completed. Incorrect syntax near ‘Sep’** which is the current month but I don’t know how to correct it. I can tell that the date is being extracted but this error provides nothing to help me. I have looked at all the blogs and ignition discussions but none have been specific to this or worked. DTReport is my downtime report and t\_stamp is the time stamp column of my report. I only want to extract the last 8 hours of input to the table. If someone also knows how to extract only a certain number of rows that would also be helpful since none of the online info has helped.

SELECT \* From DTReport  
where t\_stamp \>= dateArithmetic({TimeHolder}, -8, “hour”)  
and t\_stamp \<= {TimeHolder}  
order by t\_stamp desc

---

<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:** [September 24, 2018, 7:59pm UTC](https://forum.inductiveautomation.com/t/pulling-date-range-out-of-report-table/19791/2 "2018-09-24T19:59:35Z")

</div>

Brace-delimited substitution in SQL in Ignition is a simple string conversion, with the result going straight to your database for its syntax parser. If you cannot use ‘?’ substitution, you must handle all of the string formatting and value quoting that your DB will need to get TimeHolder in a format it accepts.

Things like dateArithmetic() are being sent to your DB, not executed in Ignition. You’ll have to compute that as a parameter, too.

Both timestamp formatting and row limiting vary by DB brand. What DB are you using?

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [September 24, 2018, 8:36pm UTC](https://forum.inductiveautomation.com/t/pulling-date-range-out-of-report-table/19791/3 "2018-09-24T20:36:04Z")

</div>

Microsoft SQL Server. I am not a python programmer but am trying to get informed. I have already created a table with changing dropdowns so selections can be made based on previous selections and i have created a search function to isolate items in the table. The last function i am trying to accomplish is emailing downtime reports every 8 hours to supervisors. I have the email function working but just need to isolate data from the last 8 hours based on the timestamp of the entry.
