Bug #29915 Minor documentation fix
Submitted: 19 Jul 2007 21:33 Modified: 20 Jul 2007 0:24
Reporter: Sheeri Cabral (Candidate Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1, 5.0, and the 3,4,4.1 docs OS:Any
Assigned to: CPU Architecture:Any
Tags: date, date format

[19 Jul 2007 21:33] Sheeri Cabral
Description:
on 

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
and
http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html

The documentation states that both %h and %I are the formatting strings for "Hours (01-12)".

In actuality, %h is "Hours (1-12)" -- no leading 0.

How to repeat:
go to the webpage, search for %h

in a client window, do:
SELECT STR_TO_DATE("Wednesday, July 04, 2007 02:02 AM","");

Suggested fix:
just take out the leading 0 in the documentation.
[19 Jul 2007 21:50] Paul DuBois
mysql> select date_format(now(),'%h %I');
+----------------------------+
| date_format(now(),'%h %I') |
+----------------------------+
| 04 04                      | 
+----------------------------+

Looks like two digits to me.
[19 Jul 2007 23:06] Sheeri Cabral
Very odd...

I was doing this:

mysql> select date(str_to_date('Sunday, July 15, 2007 2:10 PM','%W, %M %d, %Y %h:%i %p'));
+-----------------------------------------------------------------------------+
| date(str_to_date('Sunday, July 15, 2007 2:10 PM','%W, %M %d, %Y %h:%i %p')) |
+-----------------------------------------------------------------------------+
| 2007-07-15                                                                  | 
+-----------------------------------------------------------------------------+

And was getting a NULL value when I used %I instead of %h.  Of course I can't replicate it now.....

but then how would one get the 12-hour-format hour without leading zeros?
[19 Jul 2007 23:20] Jim Winstead
%l (lowercase L) is the format specifier for 12-digit hour with no leading 0, according to the docs.