# Format A Date As A String
__*DATE_FORMAT function*__
__*GET_FORMAT function*__
__*Date and time format*__
+ `DATE_FORMAT()`  
  + `http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html#function_date-format`  
+ `GET_FORMAT()`  
  + For example: `GET_FORMAT({DATE|TIME|DATETIME}, {'EUR'|'USA'|'JIS'|'ISO'|'INTERNAL'})`  
```
tidb> SELECT 
   -> date_format(now(), '%a %Y-%m-%d %T'), date_format(now(), '%Y-%m-%d %r'),
   -> date_format(now(), '%W, %M %e, %Y'), date_format(now(), '%a, %b %e %l:%i %p'),
   -> date_format(now(), '%d-%b-%Y'), date_format('2013-11-23 22:23:00', '%a, %b %e, %Y'),
   -> date_format(now(), '%M %e, %Y %H:%i'), date_format(now(), '%W, the %D of %M')\G
*************************** 1. row***************************
               date_format(now(), '~!@%a %Y-%m-%d %T@!~'): Thu 2022-01-06 10:28:24
                  date_format(now(), '~!@%Y-%m-%d %r@!~'): 2022-01-06 10:28:24 AM
                date_format(now(), '~!@%W, %M %e, %Y@!~'): Thursday, January 6, 2022
           date_format(now(), '~!@%a, %b %e %l:%i %p@!~'): Thu, Jan 6 10:28 AM
                     date_format(now(), '~!@%d-%b-%Y@!~'): 06-Jan-2022
date_format('2013-11-23 22:23:00', '~!@%a, %b %e, %Y@!~'): Sat, Nov 23, 2013
              date_format(now(), '~!@%M %e, %Y %H:%i@!~'): January 6, 2022 10:28
             date_format(now(), '~!@%W, the %D of %M@!~'): Thursday, the 6th of January
```

------------------------------------------------------------
The ISO format refers to ISO 9075.
The popular specifiers are:
Other specifiers include
%a: Abbreviation for weekday name (Sunday... (Saturday)
%b: Abbreviated month name (January... December)
%d: Day of the month (0,1,2...)
%m: digital month (1... 12)
%r: 12 hour time (hh:mm:ss followed by AM or PM)
%T: 24 hour time (hh:mm:ss)
%Y: Four-digit year (YYYY)
```
tidb> select 20011212121212 + interval 1 day;
+---------------------------------+
| 20011212121212 + interval 1 day |
+---------------------------------+
| 2001-12-13 12:12:12             |
+---------------------------------+
1 row in set (0.00 sec)

tidb> select get_format(DATETIME, 'INTERNAL');
+----------------------------------+
| get_format(DATETIME, 'INTERNAL') |
+----------------------------------+
| %Y%m%d%H%i%s                     |
+----------------------------------+
1 row in set (0.00 sec)
```
