I need a iSeries DB2 SQL query which can transform this timestamp 1/1/1900 12:00:00 AM
into 00:00:00
(handling the 12h to 24h time convertion). The scalar functions I've used don't handle this time format, the only way I managed to support this was with the following query:
SELECT (
CASE
WHEN LOCATE('PM', '1/12/1900 12:00:00 AM') = 0 THEN
REPLACE(CHAR(TIME(TIMESTAMP_FORMAT('1/12/1900 12:00:00 AM', 'DD/MM/YYYY HH24:MI:SS'))) , '.', ':' )
ELSE
REPLACE(CHAR(TIME(TIMESTAMP_FORMAT('1/12/1900 12:00:00 AM', 'DD/MM/YYYY HH24:MI:SS')) + 12 HOURS) , '.', ':' )
END)
FROM SYSIBM.SYSDUMMY1;
Is there a better way to achieve the objective ?
EDIT 6/JUN/2014
I've found that it might be possible to set the date format (ISO,USA, ...) in the connection string, which would solve all of the problems I'm currently having with this, but, I haven't found the correct parameter name to achieve that.
Assuming you have specified the correct values on the connection to indicate the correct date and time formats, if you can then convert/source the date and time values separately, you can then use the below query for conversion to your desired format: