在Derby WHERE子句中使用timestampdiff [英] Using timestampdiff in a Derby WHERE clause
问题描述
我想在Derby数据库中模拟以下类型的查询(即Microsoft SQL Server语法)的效果。目标是返回表中 someColumn中存储的日期少于7天的所有记录。这是我希望实现的Microsoft SQL语法...
I would like to simulate the effect of the following type of query (that is in Microsoft SQL Server syntax) in a Derby database. The goal is to return all records in the table where the date stored in "someColumn" is less than 7 days old. Here is the Microsoft SQL syntax for what I wish to achieve...
select * from someTable其中datediff(dd,someColumn,getdate() )< 7
我已经确定在Derby中它将涉及到使用timestampdiff函数。但是我不知道Derby中WHERE子句中函数用法的语法,我找不到任何示例。我发现了很多在返回的内容子句中使用函数的示例,例如...
I have been able to determine that in Derby it will involve use of the timestampdiff function. But the syntax of the usage of functions in a WHERE clause in Derby is unknown to me and I cannot find any examples. I have found many examples where a function is used in the "what to return" clause, such as this...
select {fn timestampdiff (SQL_TSI_HOUR,开始日期,结束日期)}作为diff
但是我还没有找到如何在WHERE子句中使用此类函数的示例。
But I have not found an example of how to use such a function in a WHERE clause.
我承认我的问题确实是我如何在Derby WHERE子句中使用函数,是的,这很基本。我也发誓在发布之前我已经尽力寻找示例。希望有人能提供帮助。
I acknowledge that my question is really "how do I use a function in a Derby WHERE clause", and yes, it's pretty basic. I also swear that I have really tried hard to find examples before posting. I hope someone can help.
推荐答案
您可以在原始补丁电子邮件,
SELECT * FROM t WHERE {fn TIMESTAMPDIFF( SQL_TSI_DAY, CURRENT_DAY, promisedDate)} <= 1
这篇关于在Derby WHERE子句中使用timestampdiff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!