db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maciej Bliziński <maciej.blizin...@magnum2.pl>
Subject How to get a difference between two dates?
Date Sun, 07 Aug 2005 07:20:24 GMT
Hello everybody,

I have a question about getting a date difference in Derby. I tried
Derby online docs, Google (web and newsgroups) and got no results.

For example, in PostgreSQL I can get a difference of two dates:

SELECT '2000-01-10'::DATE - '2000-01-01'::DATE AS date_diff;
 date_diff
-----------
         9
(1 row)

Similar thing with Derby brings an error message:

ij> SELECT DATE('2000-01-10') - DATE('2000-01-01') AS date_diff FROM
dict_country;
ERROR 42Y95: The '-' operator with a left operand type of 'DATE' and a
right operand type of 'DATE' is not supported.

("FROM dict_country" was added only because Derby needs a FROM clause,
while PostgreSQL doesn't)

So, if substraction of two dates is not supported, how can I get a
difference in days between two dates? 

-- 
Maciej Bliziński <maciej.blizinski@magnum2.pl>
Software development, server administration.


Mime
View raw message