Support Questions

Find answers, ask questions, and share your expertise

Hive Date field and time field concat

avatar
New Contributor

I have a date column thats a string and a separate time column thats a string I want to combine these into one column but can't get it to work.  

When I use this statement with hard coded values it works but when I plug in field names I just get null.

 

from_unixtime(unix_timestamp('08-22-2022 15:25:42.23' ,'MM/dd/yyyy HH:mm:ss'), 'yyyy-MM-dd HH:mm:ss') 

 

however this doesn't work:

,from_unixtime(unix_timestamp(concat(cl_date , ' ', cl_time) , 'MM/dd/yyyy HH:mm:ss'), 'yyyy-MM-dd HH:mm:ss') f

 

Should I not use concat?

1 REPLY 1

avatar
Master Collaborator

Hi @vz 

 

If both columns are in string i think you can use concat or concat_ws, Can you check below articles and see if this helps?

https://community.cloudera.com/t5/Support-Questions/HIVE-Concatenates-all-columns-easily/td-p/180208

https://blog.fearcat.in/a?ID=01600-32e80587-5a71-411e-835b-ed905cb1b61a

https://stackoverflow.com/questions/51211278/concatenate-multiple-columns-into-one-in-hive

 

Note: If my reply answers your question please give a thumbs up and accept it as a solution.

 

Regards,

Chethan YM