Extract TIME from DATETIME - informix

fenix picture fenix · Aug 1, 2014 · Viewed 14.8k times · Source

I have lost few hours looking for one row solution and didn't manage to find it. I have some value (2013/01/03 07:13:26.000) and I want to extract time part to get this: 07:13:26 so I can store it in another database as stage layer in ETL process.

When I try select my_datetime::datetime hour to second, I still get full timestamp.

Thanks.

EDIT: Sorry, source column is datetime, NOT timestamp.

Answer

fenix picture fenix · Aug 1, 2014

Ok, I managed to do this:

SELECT to_char(extend (my_datetime_column, hour to second),'%H:%M:%S') as my_time FROM my_table

Hope it will help someone!