All Forums General
anusuit1190 13 posts Joined 05/15
06 Aug 2015
Changing time format and adding to date

Hello,
I have time in format HH:MM and date in format mm/dd/yyyy. I want COL1 with time formated as HH:MM:SS and COL2 a combination of COL1 and date in format MM/DD/YYYY HH:MM:SS.
Also, then I need to subtract COL3 (format mm/dd/yyy hh:mm:ss) from COL2.
How can I do this?
 

sakthikrr 53 posts Joined 07/12
25 Aug 2015

Something like will help you I think..


select
cast('09:26'||':00' as time) as col1, 
CAST(  current_date AS TIMESTAMP(0)) + (col1 - TIME '00:00:00' HOUR TO SECOND) as col2,
(current_timestamp -  col2) DAY(4) TO SECOND as col3;

Thanks!
-Sakthi

Sakthi

You must sign in to leave a comment.