I was answering a question about SQL formatting recently and noticed in documentation two ways to define seconds %s
and %S
They both seem to do described the same:
%S - Seconds (00..59)
%s - Seconds (00..59)
and
SELECT STR_TO_DATE('2014-07-09 23:30:00', '%Y-%m-%d %H:%i:%s');
SELECT STR_TO_DATE('2014-07-09 23:30:00', '%Y-%m-%d %H:%i:%S');
give same result.
So is it historic like leftovers from some early version or they are two different things in some way?
They are the same things. I think its the historic leftover. As they both produce the same result.
I think the layout given by Mark in the same link is helpful:
+--------------+----------+--------------------+
| metric | variant | result |
+--------------+----------+--------------------+
| microseconds | %f | 000000..999999 |
| seconds | %s or %S | 00..59 |
| minutes | %i | 00..59 |
| hours | %H | 00...23 |
| | %h or %I | 00...12 |
| | %k | 0...23 |
| | %l | 1...12 |
| day | %a | Sun...Sat |
| | %D | 1st, 2nd, 3rd |
| | %d | 0.31 |
| | %e | 0..31 |
| | %j | 001...366 |
| | %W | Sunday...Sat |
| | %w | 0...6 |
| week | %U | 00...53 per Sun |
| | %u | 00...53 per Mon |
| * | %V | 01...53 per Sun |
| * | %v | 01...53 per Mon |
| month | %b | Jan...Dec |
| | %c | 0...12 |
| | %M | January...December |
| | %m | 00...12 |
| year | %Y | 1999 |
| | %y | 99 |
| * | %X | 1999 |
| * | %x | 99 |
| time | %r | 01:31:12 pm |
| | | %T | 01:31:12 pm |
| | %p | AM or PM |
| Percent sign | %% | % |
+--------------+----------+--------------------+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.