用于从时间戳中减去时间的 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:19:24  来源:igfitidea点击:

Oracle SQL query for subtracting time from timestamp

sqloracletimetimestampintervals

提问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')