Posted: Thu Sep 02, 2010 6:09 am Post subject: Timestamp does npot work
Apprentice
Joined: 24 Aug 2010 Posts: 27
Hi,
I would like to subtract two timestamp but it returns null:
DECLARE T2 TIMESTAMP;
SET T2 = CURRENT_TIMESTAMP;
DECLARE T1 TIMESTAMP;
SET T1 = CAST('2010-01-01 12:00:00' AS TIMESTAMP);
SET OutputRoot.XMLNSC.DAY_ELAPSED = (T2-T1) DAY;
The OutputRoot.XMLNSC.DAY_ELAPSED is null ???
I have finded esql example, that also don't work:
Declare D Interval (CURRENT_DATE - Date '2010-01-01') DAY;
Declare H Interval (CURRENT_TIME - Time '12:00:00') HOUR TO SECOND;
Posted: Thu Sep 02, 2010 7:03 am Post subject: Re: Timestamp does npot work
Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
kuzman wrote:
I have finded esql example, that also don't work:
Finded where? It looks a bit odd.
I'd consider something more like this (untested) snippet:
Code:
SET OutputRoot.XMLNSC.DAY_ELAPSED = EXTRACT DAY FROM(T2-T1)
Also I don't think you can initialise an INTERVAL data type like this:
Code:
Declare D Interval (CURRENT_DATE - Date '2010-01-01') DAY;
Declare H Interval (CURRENT_TIME - Time '12:00:00') HOUR TO SECOND;
You need to look up CAST, INTERVAL & EXTRACT in the InfoCenter. There are some code snippits there which might be useful. _________________ Honesty is the best policy.
Insanity is the best defence.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum