Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 43452 invoked from network); 10 Apr 2010 04:55:14 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Apr 2010 04:55:14 -0000 Received: (qmail 93841 invoked by uid 500); 10 Apr 2010 04:55:14 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 93711 invoked by uid 500); 10 Apr 2010 04:55:14 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 93704 invoked by uid 99); 10 Apr 2010 04:55:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Apr 2010 04:55:13 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_HELO_PASS,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Apr 2010 04:55:07 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1O0SiU-0001g6-OV for derby-user@db.apache.org; Fri, 09 Apr 2010 21:54:46 -0700 Message-ID: <28199979.post@talk.nabble.com> Date: Fri, 9 Apr 2010 21:54:46 -0700 (PDT) From: "el.pregunton" To: derby-user@db.apache.org Subject: Re: Timestamp Arithmetic In-Reply-To: <455A1108.60607@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: olvincortez@gmail.com References: <455A01B1.6030404@voxeo.com> <455A1108.60607@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Two questions that the Derby Documentation does not mentions, What happens when the 1st timestamp is more recent than the 2nd in the timestampdiff function? and what is the result when the 2nd timestamp is more recent than the 1st? thanks Rajesh Kartha-2 wrote: > > Jose de Castro wrote: > >> I trying to calculate the duration (in seconds) between two >> timestamps. Historically, I have either used a non-standard function >> such as DateDiff in SQL Server and MySQL or performed a direct >> arithmetic calculation (i.e. timestamp1-timestamp2) in PostgreSQL. >> >> I have searched the reference documentation and tried both of the >> aforementioned solutions with no success. I am running the latest >> stable Derby build (10.2) on a Windows XP box. >> >> What is the correct way of doing this in Derby? >> >> >> Thanks in advance, >> >> Jose de Castro >> Senior Software Engineer >> Voxeo Corporation >> jose.decastro@voxeo.com >> >> > > Derby has TIMESTAMPDIFF and TIMESTAMPADD functions and is there in the > Reference manual at: > http://db.apache.org/derby/docs/10.2/ref/rrefjdbc88908.html > > ij> create table atab1(ts timestamp, i int, ts1 timestamp); > ij> insert into atab1 values(CURRENT_TIMESTAMP, 1, CURRENT_TIMESTAMP); > 1 row inserted/updated/deleted > ij> insert into atab1 values(CURRENT_TIMESTAMP, 2, CURRENT_TIMESTAMP); > 1 row inserted/updated/deleted > ij> select {fn TIMESTAMPDIFF(SQL_TSI_SECOND, ts1,ts)} as TS_DIFF from > atab1; > TS_DIFF > ----------- > 0 > 0 > > 2 rows selected > > HTH, > -Rajesh > > > -- View this message in context: http://old.nabble.com/Timestamp-Arithmetic-tp7342697p28199979.html Sent from the Apache Derby Users mailing list archive at Nabble.com.