How to convert date time into string?

I want to convert 202001’ into ‘2020-01’
‘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():
If you are formatting a number-string into a different pattern, then you might need substring():