datetime - Concatenating DATE and TIME in SQL DEVELOPER -
i trying combine col_1, date ( dd/mm/yy 00:00:00)
, col_2, time (hh24:mi:ss)
1 single column.
i researched few codes , tried couple (adddate()
, to_date()
), none of them work. know how combine these 2 columns when -->
a. col_1 date
, col_2 time
b. col_1 date
, col_2 char
date data types don't have specific format, can control format printing on column column basis to_char() function or can alter default display format entire session altering nls_date_format setting so:
alter session nls_date_format = 'dd/mm/yy hh24:mi:ss';
now if col_1 date column , col_2 string representation of time in hh24:mi:ss format, can convert col_2 interval data type , add col_1 so:
col_1 + cast('0 '||col_2 interval day second)
when casting time string interval need leading '0 ' represent day portion of interval. in case 0 days.
if haven't changed nls_date_format string above, can output results in desired format so:
to_char(col_1 + cast('0 '||col_2 interval day second), 'dd/mm/yy hh24:mi:ss')
however, it's best leave results in it's native date type later processing.
Comments
Post a Comment