Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 61798 invoked from network); 6 Mar 2007 06:25:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Mar 2007 06:25:45 -0000 Received: (qmail 30177 invoked by uid 500); 6 Mar 2007 06:25:53 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 30145 invoked by uid 500); 6 Mar 2007 06:25:53 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 30136 invoked by uid 99); 6 Mar 2007 06:25:53 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2007 22:25:53 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2007 22:25:44 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5800771408B for ; Mon, 5 Mar 2007 22:25:24 -0800 (PST) Message-ID: <1056522.1173162324356.JavaMail.root@brutus> Date: Mon, 5 Mar 2007 22:25:24 -0800 (PST) From: "Mayuresh Nirhali (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-2386) timestampdiff function fails when using SQL_TSI_FRAC_SECOND for datepart parameter, except for very small intervals In-Reply-To: <5899350.1172769710673.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-2386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12478275 ] Mayuresh Nirhali commented on DERBY-2386: ----------------------------------------- The SQL_TSI_FRAC_SECOND type is used for fractional timestamp differences. IF the expected difference is in seconds then SQL_TSI_SECOND should be used. This is a solution to the error that is being reported in the description. So, I think this is not a bug. http://mail-archives.apache.org/mod_mbox/db-derby-dev/200511.mbox/%3Cc25576af0511281539te6c1eefw48a9dcc993ad709c@mail.gmail.com%3E The discussion above on the derby-dev list on the same topic and that talks about returning BIGINT instead of INT. I am inclined towards NOT doing that because there is no gap between the values covered by TSI_FRAC_SECOND and TSI_SECOND. I tried a small experiment as below, ij> select * from t2; ID |STARTDATE |ENDDATE ----------------------------------------------------------------- 5 |2006-11-20 04:20:00.0 |2006-11-20 04:20:00.2 6 |2006-11-20 04:20:00.0 |2006-11-20 04:20:30.0 7 |2006-11-20 04:20:00.0 |2006-11-20 04:20:00.3 8 |2006-11-20 04:20:00.0 |2006-11-20 04:20:00.9999 4 rows selected ij> select {fn timestampdiff(SQL_TSI_FRAC_SECOND, startdate, enddate)} as diff from t2 where id =8; DIFF ----------- 999900000 1 row selected So, for all values less than 1 second the function will not fail if FRAC_SECOND is used and for values in seconds TSI_SECOND should be used. The only downside of this existing approach is that for difference in seconds (when TSI_SECOND is used) the fractional difference cannot be identified. please share your thoughts. > timestampdiff function fails when using SQL_TSI_FRAC_SECOND for datepart parameter, except for very small intervals > ------------------------------------------------------------------------------------------------------------------- > > Key: DERBY-2386 > URL: https://issues.apache.org/jira/browse/DERBY-2386 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.2.2.0 > Environment: SUSE Linux Enterprise Desktop 10 > Reporter: Don Smith > Assigned To: Mayuresh Nirhali > > Using the timestampdiff function produces and integer overflow except for very small intervals. Error message is: > [Error Code: -1, SQL State: 22003] The resulting value is outside the range for the data type INTEGER. > I inserted the following row into my test table: > insert into datetest (ID, > startdate, > enddate) values ( > 5, > '2006-11-20 04:20:00.0', > '2006-11-20 04:20:00.2'); > This test row works: > select {fn timestampdiff(SQL_TSI_FRAC_SECOND, startdate, enddate)} as diff from datetest where id = 5 > DIFF > 200000000 > The value also looks too large, which could be exacerbating the problem. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.