Support Questions
Find answers, ask questions, and share your expertise

while iam converting string to timestamp iam not seeint milliseconds its getting round off, i want to convert exactly how it was

New Contributor

input: 12/20/2012 00:54:26.001000

iam using mentioned below code..

from_unixtime(unix_timestamp("12/20/2012 00:54:26.001000", "MM/dd/yyyy HH:mm:ss.SSSSSS"),"yyyy-MM-dd HH:mm:ss.SSSSSS")

iam getting output as 2012-12-20 00:54:27

i want exact milliseconds after converting to timestamp..

Thanks in advance

1 REPLY 1

Re: while iam converting string to timestamp iam not seeint milliseconds its getting round off, i want to convert exactly how it was

Hello @Santosh Kumar!
Unfortunately, the unix_timestamp function has seconds precision 😞
Give a try to the following query:

select concat(from_unixtime(unix_timestamp(substring("12/20/2012 00:54:26.001000",1,19),"MM/dd/yyyy HH:mm:ss")),substring("12/20/2012 00:54:26.001000",20)); 

Hope this helps!