How to convert date time into string?

Hi,
I want to convert 202001’ into ‘2020-01’
or
‘2020-01-01 13:45’ into ‘202001’, how to do this? I tried many ways but

‘You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘contract_apply_date, 12) as data from l2_1_company_base_cdn_2020’ at line 2’ etc.

Thank you!

Hi @maverickqi
If you’re formatting a date-string into something, then use date_format():
https://www.w3schools.com/sql/func_mysql_date_format.asp
If you are formatting a number-string into a different pattern, then you might need substring():
https://www.w3schools.com/sql/func_mysql_substring.asp