erikbstack
erikbstack

Reputation: 13254

Select all Rows with "Now minus 30 minutes" in Oracle SQL (11g)

How do I express "now minus 30 minutes" in an Oracle SQL WHERE, so that I can compare it with a stored timestamp?

Upvotes: 6

Views: 16753

Answers (2)

xbrady
xbrady

Reputation: 1703

where yourTimestamp >= sysdate - 1/48

Explanation

sysdate - 1 (subtract 1 day)
sysdate - 1/24 (subtract 1 hour)
sysdate - 0.5/24 (subtract 30 minutes)
sysdate - 0.5 * 2/ 24 * 2 = sysdate - 1/48. 

Upvotes: 8

Eric
Eric

Reputation: 95163

The solution is either the dateadd() function or

systimestamp - INTERVAL '30' minute(1)

Upvotes: 11

Related Questions