Documentation : https://prestodb.io/docs/current/functions/datetime.html
I have epoch timestamps from which I want to extract week of the year like 2021-32, 2020-50, 2021-02 and so on.
SELECT concat(date_format(from_unixtime((CAST(my_timestamp AS BIGINT) + 19800000)/1000), '%Y'),
'-' ,
date_format(from_unixtime((CAST(my_timestamp AS BIGINT) + 19800000)/1000), '%v'))
AS week
However I am getting up some wrong values like :
week = 2021-53 for Epoch-Time corresponding to Jan 1, 2021 or Jan 2, 2021. I understand that there is a sync issue happening here but that is definitely not something I want - How do I offset so that first day of week 1 starts from the beginning of the year.