There are two(2) additional date and time functions that you might find yourself using more than all of the others combined. These are DATE_FORMAT() and TIME_FORMAT(). There is some overlap between the two in that DATE_Format() can be used to alter both DATE and TIME , but the other can not.
ex.:
DATE_FORMAT(the_date, '%r')
- Time with out seconds (11:07 PM)
ex.:
DATE_FORMAT(the_date, '%l:%i%p')
ex.:
DATE_FORMAT(the_date, '%M%D,%Y')
Term
| Usage
| Example
| %e
| Day of the month
| 1-31
| %d
| Day of the month, two(2) digits only
| 01-31
| %D
| Day with Suffix
| 1st - 31st
| %W
| Weekday name
| Sunday-Saturday
| %a
| Abbreviated weekday name
| Sun - Sat
| %c
| Month number
| 1-12
| %m
| Month number with two(2) digits
| 01-12
| %M
| Month Name
| January - December
| %b
| Month Name, Abbreviated
| Jan-Dec
| %Y
| Year number
| 2004
| %y
| two(2) digit Year number value
| 04
| %l
| Hour value
| 1-12
| %h
| Hour value, two(2) digits only
| 01-12
| %k
| Hour in 24-hour clock format
| 0-23
| %H
| Hour, 24-hour clock as two(2) digits
| 00-23
| %i
| Minutes value
| 00-59
| %S
| Seconds value
| 00-59
| %r
| Time value
| 8:17:02 PM
| %T
| Time in 24-hour clock format
| 20:17:02
| %p
| AM or PM label for Time
| AM or PM
|
|