Bug #7622 DATE_FORMAT handles going over to new year incorrectly
Submitted: 3 Jan 2005 10:14 Modified: 4 Feb 2005 10:16
Reporter: Per Nehard Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:mysql-server-4.0.20 OS:FreeBSD (FreeBSD)
Assigned to: CPU Architecture:Any

[3 Jan 2005 10:14] Per Nehard
Description:
When trying to make a report on the number of a particulat instance per week using the following SQL-statment:

select DATE_FORMAT(<date field>,'%Y%u'), count(*) from <table> where  DATE_FORMAT(<date field>,'%Y%u') < DATE_FORMAT(CURDATE(),'%Y%u') group by 1 order by 1 DESC;

it sometimes reports instances as month 00 of the new year when they actually belong to the last week of the previous year instead.

How to repeat:
Build a table with a date field and set some dates around the shifting to a new year. Some of the years that I noticed are not handled correctly in regard to this problem are: 1989, 1995, 2000 an now 2005.

Suggested fix:
It would be good if this function could handle going over to a new year in a correct way.

Feel free to contact me on per@nic.se if you need further information on this.

Thanks!

 /Per (NIC-SE, Administrator of the Country
         Code Top Level Domain for Sweden, .se)
[4 Jan 2005 10:16] MySQL Verification Team
Hello,

Thank you for the report, but I can't repeat it with 4.0.24-debug-log and with my test data.
Could you provide a repeatable test case?
[14 Feb 2005 22:54] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".