Quote:
from '2010-03-15-11.30.52.607770' to
'03/15/2010 11:30:52.607770 am/pm?
|
The issues of provided solutions are ignoring fractional seconds(or microseconds), like Lenny's Result showed.
If you dont mind the issue, that's OK.
To keep fractional seconds, you can use TIMESTAMP_FORMAT(synonym is TO_CHAR) function with rich
format-string which is available DB2 9.5 or later for LUW.
(DB2 Version 9.1 for z/OS and DB2 for i Version 6 Release 1 don't support format strings 'AM', 'PM' and 'HH12'.)
Here is an example.
Code:
------------------------------ Commands Entered ------------------------------
SELECT VARCHAR_FORMAT( current_timestamp , 'mm/dd/yyyy hh12:mi:ss.nnnnnn AM' )
FROM sysibm.sysdummy1;
------------------------------------------------------------------------------
1
--------------------------------------------------
03/16/2010 06:14:01.214000 AM
1 record(s) selected.