[英]How to write a query to fetch data from DB on the basis of timestamp
I have a task to do in which i have to write a query which can fetch the data on the basis of timestamp 我有一个任务要做,其中我必须编写一个查询,该查询可以根据时间戳获取数据
event
and other one is Time
event
,另一个是Time
Derby
data base and facing issue to get the output Derby
数据库并面临问题以获取输出 this is the error i am getting from running my query in derby 这是我在derby中运行查询时遇到的错误
error
Syntax error: Encountered "5"
error
Syntax error: Encountered "5"
my query is SELECT * FROM test WHERE Time >= CURRENT_TIMESTAMP - INTERVAL 5 minute AND Time <= CURRENT_TIMESTAMP
我的查询是
SELECT * FROM test WHERE Time >= CURRENT_TIMESTAMP - INTERVAL 5 minute AND Time <= CURRENT_TIMESTAMP
I'm not sure about the interval syntax, but you can try TIMESTAMPADD()
: 我不确定间隔语法,但是您可以尝试
TIMESTAMPADD()
:
SELECT *
FROM test
WHERE Time >= {fn TIMESTAMPADD(SQL_TSI_MINUTE, -5, CURRENT_TIMESTAMP) }
AND Time <= CURRENT_TIMESTAMP
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.