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"