I have a timestamp like that in $"my_col"
:
2022-01-21 22:11:11
with date_trunc("minute",($"my_col"))
2022-01-21 22:11:00
with date_trunc("hour",($"my_col"))
2022-01-21 22:00:00
What is a Spark 3.0 way to get
2022-01-21 22:10:00
?
I have a timestamp like that in $"my_col"
:
2022-01-21 22:11:11
with date_trunc("minute",($"my_col"))
2022-01-21 22:11:00
with date_trunc("hour",($"my_col"))
2022-01-21 22:00:00
What is a Spark 3.0 way to get
2022-01-21 22:10:00
?
Copyright © 2021 Jogjafile Inc.
Convert the timestamp into seconds using
unix_timestamp
function, then perform the rounding by dividing by600
(10 minutes), round the result of division and multiply by 600 again:You can also truncate the original timestamp to hours, get the minutes that your round to 10 and add them to truncated timestamp using interval: