Search code examples
sqldatetimewhere-clausesybasesybase-asa

Show record data in the last 1 hour in sybase ASA11


select * from Trx   
where 
RequestTimestamp BETWEEN DATE(NOW()) AND DATEADD(HOUR, -1, GETDATE())

I have this sql code from sybase ASA11, hoping to show data in last 1 hour, but it just shows today's record from 00:00:00.000 AM till now(). What is wrong with my script, so it can show all of record from 1 last hour to now(). Can somebody help me?


Solution

  • It looks like you want:

    where requestTimestamp >= dateadd(hour, -1, getdate())
    

    If you have requestTimestamp in the future, then an upper bound is also needed:

    where requestTimestamp between dateadd(hour, -1, getdate()) and getdate();