Convert Integer to String in Presto

Convert Integer to String in Presto

I am trying to convert an integer (e.g. 20211008) to a string format (2021-10-08) to use as a primary key in a separate sub-query. I have tried the following:

primary_key = cast(PARSE_DATETIME(cast(integer as VARCHAR),'yyyyMMdd') as date) 

but receive an error: =' cannot be applied to varchar, date"

7
Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.