0
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?

GMB
  • 216,147
  • 25
  • 84
  • 135

1 Answers1

1

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();
GMB
  • 216,147
  • 25
  • 84
  • 135