Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SQL query for subtracting time from timestamp

I have a problem building a query in oracle. I have table with column "DATE_CREATE", which has a type of "TIMESTAMP". Example of one value is:

2012-10-20 05:43:47:001000

I would like to build a where clause for selecting rows with create column newer than 15 minutes ago. For now I have a query like this (which return no rows, but it should):

SELECT DATE_CREATE,ID
FROM TABLE
WHERE DATE_CREATE >= CURRENT_TIMESTAMP - interval '15' minute

Help please...

like image 499
marc_s Avatar asked Dec 08 '22 08:12

marc_s


1 Answers

Try this:

SELECT DATE_CREATE,ID
FROM TABLE
WHERE DATE_CREATE >= CURRENT_TIMESTAMP - NUMTODSINTERVAL(15, 'MINUTE')
like image 83
StephaneM Avatar answered Dec 11 '22 08:12

StephaneM