IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Difference b/w timestamps


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Mon Dec 20, 2010 3:04 pm
Reply with quote

Hi,
I;m trying to get the difference between two timestamp ,when running this query in SPUFI

Code:

   SELECT
    TIMESTAMP('2010-12-20-02.33.05.690798') -
    TIMESTAMP('2010-12-20-01.33.05.690798' ) 
      FROM SYSIBM.SYSDUMMY1;               


resulted in :10000.000000

But the same when tried to put in my code as
Code:

   EXEC SQL
       SET :A =  TIMESTAMP('2010-12-20-02.33.05.690798') -
                      TIMESTAMP('2010-12-20-01.33.05.690798' ) 
  END-EXEC.


   


is resulting in an error saying UNDEFINED OR UNUSABLE HOST VARIABLE A.

A is declared as PIC9(04)V9(06) COMP-3.

As this has to go in the table to a field of DECIMAL(10,6) i declared A in the above format.

Is the above correct??? please help me in this regards.[/quote]
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Dec 20, 2010 3:17 pm
Reply with quote

Why don't you check the manual?:

DB2 Vsn 8 SQL Reference wrote:
Subtracting timestamps: The result of subtracting one timestamp (TS2) from
another (TS1) is a timestamp duration that specifies the number of years, months,
days, hours, minutes, seconds, and microseconds between the two timestamps. The
data type of the result is DECIMAL(20,6).


further information can be obtained in the Application Programmers manual.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Dec 20, 2010 3:33 pm
Reply with quote

There is a section in the SQL V9 reference manual for duration calculations:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/DSNSQK10/2.22.5?DT=20070125023435
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts What is the difference between Taskty... Compuware & Other Tools 2
No new posts Difference between VALIDPROC and CHEC... DB2 3
No new posts Difference between CEE3250C and CEE3204S COBOL Programming 2
Search our Forums:

Back to Top