What is the optimal way to find transactions that ...
# suiteql
j
What is the optimal way to find transactions that were created over 20 minutes ago. The only way I have found to do this is to use TO_CHAR but this makes the query much slower than it should be. Here's an example of the SuiteQL I am currently using
Copy code
select count(*) as value
from transaction T
where type='SalesOrd' 
    and trandate >= '01/04/2023'
    and status = 'B'
    and TO_CHAR(T.createddate, 'YYYY-MM-DD HH:MI:SS') <
        TO_CHAR ( SYSDATE - ( 20 / 1440 ), 'YYYY-MM-DD HH:MI:SS' )
s
You can try using a TIMESTAMP literal, e.g.
WHERE createddate <= TIMESTAMP '2023-12-31 12:00:00 UTC'
and also you can try reversing the condition using
AND NOT
j
Thank you that definitely seems to be more performant