You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by hezjing <he...@gmail.com> on 2011/05/03 11:13:45 UTC
Date manipulation in Derby
Hi
With MySQL, I can actually manipulate the date using the built-in function
like:
SELECT DATE_ADD('2010-12-31 23:59:59', INTERVAL 1 DAY)
May I know if there is similar function in Derby? How do we manipulate the
date in Deby?
--
Hez
Re: Date manipulation in Derby
Posted by Knut Anders Hatlen <kn...@oracle.com>.
Lukas Eder <lu...@gmail.com> writes:
>> Derby supports the JDBC escape function TIMESTAMPADD, documented here:
>> http://db.apache.org/derby/docs/10.8/ref/rrefjdbc88908.html
>>
>> Example:
>>
>> ij> values {fn timestampadd(SQL_TSI_DAY, 1, timestamp('2010-12-31
>> 23:59:59'))};
>
> Are there any plans to make this function available in a more regular
> syntax? Or what are the reasons that this is only possible using this
> "JDBC escape function" syntax?
I'm not aware of any plans to implement alternative syntax for
manipulating timestamps. The JDBC escape function syntax was probably
chosen because it was defined by a standard and therefore believed to be
more portable.
--
Knut Anders
Re: Date manipulation in Derby
Posted by Lance Andersen - Oracle <La...@oracle.com>.
Few databases support intervals.
We have discussed adding interval support to JDBC and it will probably happen via JSR 310.
Best,
Lance
On May 4, 2011, at 3:01 PM, Knut Anders Hatlen wrote:
> dag.wanvik@oracle.com (Dag H. Wanvik) writes:
>
>> Rick Hillegas <ri...@oracle.com> writes:
>>
>>> I don't see an existing JIRA for this issue. Feel free to log one.
>>
>> Rick, do you know if there is a standard way of doing this (beyond the
>> JDBC escape function)? I didn't find anything in the standard. It could
>> be that this is one of those things that are not standardized and the
>> presence of the JDBC escape is there to cover for vendors differing
>> implementations of this. If so, we would be hestitant to add this unless
>> most major vendors agreed on this syntax.
>
> Hi Dag,
>
> SQL:2003, part 2, has a section 4.6.4 Operations involving datetimes and
> intervals. If my understanding is correct, databases that support
> intervals would allow you to write things like:
>
> VALUES TIMESTAMP('2010-12-31 23:59:59') + INTERVAL '1' DAY
>
> --
> Knut Anders
Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
Lance.Andersen@oracle.com
Re: Date manipulation in Derby
Posted by Knut Anders Hatlen <kn...@oracle.com>.
dag.wanvik@oracle.com (Dag H. Wanvik) writes:
> Rick Hillegas <ri...@oracle.com> writes:
>
>> I don't see an existing JIRA for this issue. Feel free to log one.
>
> Rick, do you know if there is a standard way of doing this (beyond the
> JDBC escape function)? I didn't find anything in the standard. It could
> be that this is one of those things that are not standardized and the
> presence of the JDBC escape is there to cover for vendors differing
> implementations of this. If so, we would be hestitant to add this unless
> most major vendors agreed on this syntax.
Hi Dag,
SQL:2003, part 2, has a section 4.6.4 Operations involving datetimes and
intervals. If my understanding is correct, databases that support
intervals would allow you to write things like:
VALUES TIMESTAMP('2010-12-31 23:59:59') + INTERVAL '1' DAY
--
Knut Anders
Re: Date manipulation in Derby
Posted by Rick Hillegas <ri...@oracle.com>.
On 5/4/11 10:38 AM, dag.wanvik@oracle.com wrote:
> Rick Hillegas<ri...@oracle.com> writes:
>
>> I don't see an existing JIRA for this issue. Feel free to log one.
> Rick, do you know if there is a standard way of doing this (beyond the
> JDBC escape function)? I didn't find anything in the standard. It could
> be that this is one of those things that are not standardized and the
> presence of the JDBC escape is there to cover for vendors differing
> implementations of this. If so, we would be hestitant to add this unless
> most major vendors agreed on this syntax.
>
> Thank,
> Dag
>
Hi Dag,
It looks to me as though an arithmetic on datetime types is defined by
part 2 of the SQL Standard, section 6.30 (<datetime value expression>).
At first blush that arithmetic seems even more cumbersome than the JDBC
escape syntax which troubles Lukas.
Derby does support convenience functions which don't appear in the SQL
Standard. Mostly, the major vendors agree on the syntax for those
convenience functions. I agree that divergence across the major vendors
would be a problem for this proposal. I haven't studied what the major
vendors do here, though.
Thanks,
-Rick
Re: Date manipulation in Derby
Posted by "Dag H. Wanvik" <da...@oracle.com>.
Rick Hillegas <ri...@oracle.com> writes:
> I don't see an existing JIRA for this issue. Feel free to log one.
Rick, do you know if there is a standard way of doing this (beyond the
JDBC escape function)? I didn't find anything in the standard. It could
be that this is one of those things that are not standardized and the
presence of the JDBC escape is there to cover for vendors differing
implementations of this. If so, we would be hestitant to add this unless
most major vendors agreed on this syntax.
Thank,
Dag
Re: Date manipulation in Derby
Posted by Lukas Eder <lu...@gmail.com>.
Hi Rick and Knut,
> Hi Lukas,
>
> I don't see an existing JIRA for this issue. Feel free to log one.
>
> Thanks,
> -Rick
Done:
https://issues.apache.org/jira/browse/DERBY-5214
Re: Date manipulation in Derby
Posted by Rick Hillegas <ri...@oracle.com>.
On 5/3/11 4:52 AM, Lukas Eder wrote:
>> Derby supports the JDBC escape function TIMESTAMPADD, documented here:
>> http://db.apache.org/derby/docs/10.8/ref/rrefjdbc88908.html
>>
>> Example:
>>
>> ij> values {fn timestampadd(SQL_TSI_DAY, 1, timestamp('2010-12-31 23:59:59'))};
> Are there any plans to make this function available in a more regular
> syntax? Or what are the reasons that this is only possible using this
> "JDBC escape function" syntax? I'd expect this to be possible too:
>
> timestampadd(SQL_TSI_DAY, 1, timestamp('2010-12-31 23:59:59'))
>
Hi Lukas,
I don't see an existing JIRA for this issue. Feel free to log one.
Thanks,
-Rick
Re: Date manipulation in Derby
Posted by Lukas Eder <lu...@gmail.com>.
> Derby supports the JDBC escape function TIMESTAMPADD, documented here:
> http://db.apache.org/derby/docs/10.8/ref/rrefjdbc88908.html
>
> Example:
>
> ij> values {fn timestampadd(SQL_TSI_DAY, 1, timestamp('2010-12-31 23:59:59'))};
Are there any plans to make this function available in a more regular
syntax? Or what are the reasons that this is only possible using this
"JDBC escape function" syntax? I'd expect this to be possible too:
timestampadd(SQL_TSI_DAY, 1, timestamp('2010-12-31 23:59:59'))
Re: Date manipulation in Derby
Posted by Knut Anders Hatlen <kn...@oracle.com>.
hezjing <he...@gmail.com> writes:
> Hi
>
>
> With MySQL, I can actually manipulate the date using the built-in
> function like:
>
> SELECT DATE_ADD('2010-12-31 23:59:59', INTERVAL 1 DAY)
>
> May I know if there is similar function in Derby? How do we manipulate
> the date in Deby?
Derby supports the JDBC escape function TIMESTAMPADD, documented here:
http://db.apache.org/derby/docs/10.8/ref/rrefjdbc88908.html
Example:
ij> values {fn timestampadd(SQL_TSI_DAY, 1, timestamp('2010-12-31 23:59:59'))};
1
-----------------------------
2011-01-01 23:59:59.0
1 row selected
--
Knut Anders