I have a large query, where I group things by:
date_format(date, '%Y-%m')
and it works perfectly fine. I want later to turn it back to date to use datediff or whatever other date functions, then go back to this format. Of course, I tried STR_TO_DATE function:
str_to_date(date_format(date, '%Y-%m'),'%Y-%m')
but it returns NULL. According to documentation, it should return date in format 2020-01-00, but it doesn't. When I tried just:
select str_to_date('2020-01-01','%Y-%m-%d')
It works. I also tried:
SELECT STR_TO_DATE('9','%m')
directly from documentation, but it returns null too. I have MySQL 8.0.23.
I found some questions on it and tried all the things I found there: MySQL STR_TO_DATE() function returns null I also tried to collate it, but without success. Is there some workaround for it?