Named query error "out of index"

I am trying to return the max value for a row between 2 predefined time stamps from my DB but I keep getting error out of index.

the named query:

/*SELECT TOP 1 "nCycles_Trex_01","nGoodParts_Trex_01","nCycles_Trex_02","nGoodParts_Trex_02" FROM TrexTest00 WHERE t_stamp <= :date ORDER BY trextest00_ndx DESC 
*/

--SELECT MAX 'nCycles_Trex_01',"nGoodParts_Trex_01","nCycles_Trex_02","nGoodParts_Trex_02" FROM TrexTest00 WHERE t_stamp >= :date AND t_stamp <= :date_end
 --SELECT :date --AND ADDTIME( ':date' , 20 )
SELECT MAX(nCycles_Trex_01) FROM TrexTest00 WHERE t_stamp >= '2022-6-09 13:59:16' AND t_stamp <= '2022-6-09 13:59:20' --where CONVERT(Time, t_stamp) BETWEEN  CONVERT(Time, :date )  and  CONVERT(Time,  :date_end ) 

I have tried all those different approaches (every line) but keep getting the error when I try to use the max function. I have 2 dateTime parameters for the corresponding start and end date

image

Does anyone know why it isnt working?

To pass parameters this way, this must be a named query, right? When you test the named query in the ‘Testing’ tab, does it return any results?

When I test the named query that error message above appears (The index is out of range). When I bind a component to it I also get the same error

Have you tried it as you posted it here or were you just condensing all of your tries into a single code block?

Named Queries do not handle comments well all of the time, especially if the comments include parameters.

Also, can you show the details of the error, preferably in a code block.

2 Likes

Deleting the commented lines was the solution. Thanks!

1 Like