If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Determine Maximum Timestamp from a Set

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-09, 22:13
raizel raizel is offline
Registered User
 
Join Date: Dec 2009
Posts: 5
Determine Maximum Timestamp from a Set

Hi guys,

Probably most or some of you know the solution to this. As the title suggests, I have a set of Timestamps. I want to get the highest timestamp.
Of course I can just use the case statement like:

Code:
CASE
WHEN
  TIMESTAMP('2004-01-26 11:50:00.000000') > TIMESTAMP('2003-04-23 08:00:00.000000')
THEN
   TIMESTAMP('2004-01-26 11:50:00.000000')
WHEN...........
THEN.....

ELSE TIMESTAMP('2003-04-23 08:00:00.000000')
end
is there an easy way to do this? Or a way that I can make it using the MAX function:
Code:
MAX(TIMESTAMP('2004-01-26 11:50:00.000000'),TIMESTAMP('2003-04-23 08:00:00.000000'),.......,......)
Thanks!
Reply With Quote
  #2 (permalink)  
Old 12-21-09, 01:29
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
Yes, you can use MAX(timestamp1,timestamp2....)
Reply With Quote
  #3 (permalink)  
Old 12-21-09, 01:34
raizel raizel is offline
Registered User
 
Join Date: Dec 2009
Posts: 5
Quote:
Originally Posted by umayer View Post
Yes, you can use MAX(timestamp1,timestamp2....)
I tried. But its telling me that there is no authorized routine with the same signature.

Code:
SELECT MAX(A.DATE_S, B.DATE_S, C.DATE_S) AS DATE_S FROM ......
Reply With Quote
  #4 (permalink)  
Old 12-21-09, 02:38
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Referencing manuals,
MAX(timestamp1,timestamp2....) is supported on DB2 9.5 for LUW, DB2 Version 7 for z/OS and DB2 for iSeries.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On