You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Tzahi File <tz...@is.com.INVALID> on 2021/08/04 20:42:47 UTC
Convert timestamp to unix miliseconds
Hi All,
I'm using spark 2.4 and trying to convert a timestamp column to unix with
milliseconds using the unix_timestamp function.
I tried to convert the result to double cast(unix_timestamp(timestamp) as
double).
I also tried using the timestamp format "yyyy-MM-dd HH:mm:ss.sss" and no
matter what I already tested I just kept getting the unix time in seconds.
Looking for any new ideas.
Thanks.
Re: Convert timestamp to unix miliseconds
Posted by Artemis User <ar...@dtechspace.com>.
Apparently you were not using the right formatting string. For
sub-second formatting, use capital S instead of lower case s. See
Spark's doc at
https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html. Hope
this helps...
-- ND
On 8/4/21 4:42 PM, Tzahi File wrote:
> Hi All,
>
> I'm using spark 2.4 and trying to convert a timestamp column to unix
> with milliseconds using the unix_timestamp function.
>
> I tried to convert the result to double cast(unix_timestamp(timestamp)
> as double).
> I also tried using the timestamp format "yyyy-MM-dd HH:mm:ss.sss" and
> no matter what I already tested I just kept getting the unix time in
> seconds.
>
> Looking for any new ideas.
>
>
> Thanks.
---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscribe@spark.apache.org