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’);
This outputs:
31-mei-2008 0:00:00
I would expect it to have printed out:
1-june-2008 0:00:00
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.
regards,
Wim