Bug #11326 TIME_FORMAT using "%r" returns wrong hour using 24:00:00 in TIME column
Submitted: 14 Jun 2005 16:13 Modified: 28 May 2006 21:57
Reporter: chris cohen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.12 OS:Linux (Linux (Redhat Fedora))
Assigned to: Jani Tolonen CPU Architecture:Any

[14 Jun 2005 16:13] chris cohen
Description:
select TIME_FORMAT("24:00:00", '%r'); returns 12:00:00 PM (noon); 

How to repeat:
select TIME_FORMAT("24:00:00", '%r');

mysql> select TIME_FORMAT("0:00:00", '%r');
+------------------------------+
| TIME_FORMAT("0:00:00", '%r') |
+------------------------------+
| 12:00:00 AM                  |
+------------------------------+
1 row in set (0.00 sec)

mysql> select TIME_FORMAT("12:00:00", '%r');
+-------------------------------+
| TIME_FORMAT("12:00:00", '%r') |
+-------------------------------+
| 12:00:00 PM                   |
+-------------------------------+
1 row in set (0.00 sec)

mysql> select TIME_FORMAT("24:00:00", '%r');
+-------------------------------+
| TIME_FORMAT("24:00:00", '%r') |
+-------------------------------+
| 12:00:00 PM                   |
+-------------------------------+
1 row in set (0.00 sec)

Suggested fix:
00:00:00 and 24:00:00 should both be valid TIME column entries but these time functions should interpret them as 12:00 AM (midnight).
[18 Jun 2005 6:33] Vasily Kishkin
Tested on Win 2000 Sp4, MySQL server 4.1.13

mysql> select TIME_FORMAT("24:00:00", '%r');
+-------------------------------+
| TIME_FORMAT("24:00:00", '%r') |
+-------------------------------+
| 12:00:00 PM                   |
+-------------------------------+
1 row in set (0.00 sec)

mysql>
[20 Jun 2005 12:49] chris cohen
either the time_format function isn't working properly or 24:00:00 isn't a valid TIME column entry (which it should be)
[10 Apr 2006 17:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4733
[20 Apr 2006 20:03] Chad MILLER
Please add test cases to exercise every behavior of TIME_FORMAT as you can think of.
[20 Apr 2006 20:05] Chad MILLER
(Sorry.  In my last note I was addressing the assigned developer.)
[4 May 2006 16:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/5959
[12 May 2006 14:24] Jani Tolonen
Added missing titles to tests.
[28 May 2006 21:57] Jani Tolonen
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html