用于从时间戳中减去时间的 Oracle SQL 查询
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23079345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle SQL query for subtracting time from timestamp
提问by marc_s
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:
我在 oracle 中构建查询时遇到问题。我有一个带有“DATE_CREATE”列的表,它的类型为“TIMESTAMP”。一个值的示例是:
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):
我想构建一个 where 子句来选择创建列比 15 分钟前新的行。现在我有一个这样的查询(它不返回行,但它应该):
SELECT DATE_CREATE,ID
FROM TABLE
WHERE DATE_CREATE >= CURRENT_TIMESTAMP - interval '15' minute
Help please...
请帮忙...
回答by StephaneM
Try this:
尝试这个:
SELECT DATE_CREATE,ID
FROM TABLE
WHERE DATE_CREATE >= CURRENT_TIMESTAMP - NUMTODSINTERVAL(15, 'MINUTE')