# 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)
```
