How to convert a string to timestamp with milliseconds in Hive

前端 未结 5 1769
猫巷女王i
猫巷女王i 2021-02-04 11:27

I have a string \'20141014123456789\' which represents a timestamp with milliseconds that I need to convert to a timestamp in Hive (0.13.0) without losing the milliseconds.

5条回答
  •  伪装坚强ぢ
    2021-02-04 11:50

    Let say you have a column 'birth_date' in your table which is in string format, you should use the following query to filter using birth_date

    date_Format(birth_date, 'yyyy-MM-dd HH:mm:ssSSS')
    

    You can use it in a query in the following way

    select * from yourtable
    where 
    date_Format(birth_date, 'yyyy-MM-dd HH:mm:ssSSS') = '2019-04-16 07:12:59999';
    

提交回复
热议问题