The column type is bigint and the values are
20211123
20220125
How can I change it to date:
2021-11-23
2022-01-25
CodePudding user response:
Use string functions to extract the characters, they'll automatically convert the number to a string.
SELECT CAST(CONCAT_WS('-', LEFT(colname, 4), SUBSTR(colname, 5, 2), RIGHT(colname, 2))
AS DATE) AS date
FROM yourTable