'Convert timestamp to int [closed]

I need to convert timestamp to int. Basically I am looking to convert 2022-04-20 00:21:21:123 into 20220420. I am trying below the below way but not working.

select usernumber, cast(format(created_date,'YYYYMMDD') as int)
from table1;


Solution 1:[1]

note that 'Y' and 'D' must be lowercase and your dataype isn't timestamp that's datetime type.

select usernumber, cast(FORMAT(created_date,'yyyyMMdd') as int)
from table1;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcio Rocha