Either STR_TO_DATE does not work properly or I’m doing something wrong. Consider this statement:
SELECT DATE_FORMAT( NOW(), ‘%Y%m’);
This will output ‘200806’ since we are currently June in the year 2008.
Then do this:
SELECT STR_TO_DATE(DATE_FORMAT( NOW(), ‘%Y%m’), ‘%Y%m’);
I would expect it to have printed out:
Anybody has an idea why this might happen?
I need this because I want to group by month and want to have a column ‘CalculatedDate’ which contains a real date with the first of each month in it.