View Single Post
  #10 (permalink)  
Old 03-17-10, 14:46
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Thumbs up

Quote:
Originally Posted by tonkuma View Post
Lenny,

Code:
when hour(current time) = 0 
               then char(current time + 12 hour) || ' AM'
would be never executed.

Because, there is a following description in the manual "DB2 SQL Reference".

And, the condition "hour(current time) = 0" is included in the first condition "hour(current time) < 12".
Thank you, tonkuma !

I could not understood what has to be wrong, and you find !
Also:
Code:
select char(current date, usa) || ' ' 
|| case 
        when hour(current time) = 0 
               then char(current time + 12 hour) || ' AM' 
        when hour(current time) < 12 
               then char(current time) || ' AM' 
        when hour(current time) = 12 
               then char(current time) || ' PM'       
        when hour(current time) > 12  
               then char(current time - 12 hour) || ' PM' 
   end   as "AM/PM Timestamp"
from sysibm.sysdummy1
Lenny
Reply With Quote