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

How to fetch the latest timestamp?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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: 1353
Location: Israel

PostPosted: Tue May 22, 2007 3:03 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts Timestamp difference and its average ... DB2 11
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
Search our Forums:

Back to Top