Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to fetch the latest timestamp?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
crrindia

Active User


Joined: 02 Jul 2005
Posts: 124
Location: Gurgaon

PostPosted: Tue May 22, 2007 9:33 am    Post subject: How to fetch the latest timestamp?
Reply with quote

Hi all,
in my requirement there are some timestamps for each product(ex. 5 products are there). if i want to fetch the data of latest timestamp, how to achieve it?

Thanks!
Rathna.
Back to top
View user's profile Send private message

kgumraj

Active User


Joined: 01 May 2006
Posts: 151
Location: Hyderabad

PostPosted: Tue May 22, 2007 9:58 am    Post subject:
Reply with quote

Hi,

You can use this code
Code:

EXEC SQL
         SELECT MAX(TIMESTAMP(:WS-FIRST-TIMEST),TIMESTAMP(:WS-SECOND-TIME-ST)
             INTO :MAX-TIME-ST
             FROM SYSIBM.SYSDUMMY1
END-EXEC
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Tue May 22, 2007 3:03 pm    Post subject:
Reply with quote

Code:
SELECT *
    FROM QUAL.MYTABLE
    WHERE TIMESTAMPCOL = SELECT MAX(TIMESTAMPCOL) FROM QUAL.MYTABLE

With something like this, you will get the one row having the highest timestamp.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am
No new posts Converting EBCDIC to Unicode (TimeStamp) muralikrishnan_new COBOL Programming 2 Mon Jul 25, 2016 10:42 pm
No new posts JCL to fetch schedule status from act... parasmalik20 CA Products 1 Thu Jun 02, 2016 7:11 pm
No new posts Convert Timestamp Value mrdinesh DFSORT/ICETOOL 7 Thu May 05, 2016 6:01 pm
No new posts ABEND due to FETCH FAILED jackzhang75 ABENDS & Debugging 17 Thu Mar 10, 2016 3:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us