Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 where datediff(dd, someColumn, getdate()) < 7

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, startdate, enddate)} as diff

But I have not found an example of how to use such a function in a WHERE clause.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
925 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can see an example in the original patch email,

SELECT * FROM t WHERE {fn TIMESTAMPDIFF( SQL_TSI_DAY, CURRENT_DAY, promisedDate)} <= 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...