I need to convert a string value to timestamp in Spark SQL while retaining the milliseconds part. The string value is :'2018-05-15 14:12:44.185'
. I tried to type-cast
it but it truncates the milliseconds part.
select from_unixtime(unix_timestamp('2018-05-15 14:12:44.185', 'yyyy-MM-dd HH:mm:ss.SSS'))
Can anyone please help so that the milliseconds part is also retained in the resulting value ?
Thanks
GMB :
You can use function to_timestamp() to convert the string to a timestamp, like:\n\nselect to_timestamp('2018-05-15 14:12:44.185', 'yyyy-MM-dd HH:mm:ss.SSS')\n",
2019-11-17T16:21:14