Report time conflict

I am trying to create a report on version 7.9 using a start time and end time i transfer from a table. I keep getting the following error


This is what I want to run just with the start time and end time swapped out with a parameter. And the following code works
‘SELECT [key_ndx]
,[GE_Oven]
,[t_stamp]
,[GE_Duct]
,[GE_Oven_2]
,datediff(ss,‘2019-01-20 15:00’,t_stamp) as Diff
,DATEDIFF(Hour,‘2019-01-20 15:00’, [t_stamp]) as hourpart,
DATEDIFF(minute,‘2019-01-20 15:00’, [t_stamp])%60 as minpart
FROM Ovens
WHERE t_stamp > ‘2019-01-20 15:00’ AND t_stamp < ‘2019-01-28 15:00’
ORDER BY t_stamp ASC’

This is the code that creates the error
‘SELECT [key_ndx]
,[GE_Oven]
,[t_stamp]
,[GE_Duct]
,[GE_Oven_2]
,datediff(ss,’{StartDate}’,t_stamp) as Diff
,DATEDIFF(Hour,’{StartDate}’, [t_stamp]) as hourpart,
DATEDIFF(minute,’{StartDate}’, [t_stamp])%60 as minpart
FROM Ovens
WHERE t_stamp > ‘{StartDate}’ AND t_stamp < ‘{EndDate}’
ORDER BY t_stamp ASC’

Here is the start date expression
dateFormat(
dateArithmetic(now(), -120, “hr”), //don’t forget the comma at the end of this line…
“yyyy-MM-dd HH:mm:ss”) //…as well as the outer closing ‘)’

and the end date
dateFormat(
dateArithmetic(now(), -120, “hr”), //don’t forget the comma at the end of this line…
“yyyy-MM-dd HH:mm:ss”) //…as well as the outer closing ‘)’

I have also tried using tags like the following
{Machine Status/Cure Oven/Fan StartTime} which is the value I copied to get the times in the to query.

The error in the picture shows

t_stamp '{EndDate}'

probably should be

t_stamp < '{EndDate}'

Thank you, Nick.
Yea I see what you mean. But I just verified and it is t_stamp < ‘{EndDate}’.
I even tried adding <= and it only shows the = in the error. But i do still get the error.
I had also originally tried using a between where clause and had the same error.

Try setting the query type to ‘Basic SQL Query’ from the default ‘SQL Query’
OR use parameterized entries in the ‘SQL Query’
https://docs.inductiveautomation.com/display/DOC79/SQL+Query+Data+Source

1 Like

That fixed the issue. Thank you.

1 Like