A simple strategy would be to use date_format(arg1, arg2) , where arg1 is the timestamp as a formatted string, date or timestamp, and arg2 is the string format (in arg1 ). Refer to the SimpleDateFormat java documentation for a valid argument format.
So in this case:
date_format('20141014123456789', 'yyyyMMddHHmmssSSS')
the following line will be displayed: '2014-10-14 12:34:56.789' , which can then be discarded as a timestamp:
cast(date_format('20141014123456789', 'yyyyMMddHHmmssSSS') as timestamp)
The above statement returns a timestamp (optional).
source share