Syntax
GET_FORMAT({DATE | TIME | DATETIME | TIMESTAMP}, {'EUR' | 'USA' | 'JIS' | 'ISO' | 'INTERNAL'})
Purpose
GET_FORMAT() returns a string in the specified format. You can use it together with DATE_FORMAT or STR_TO_DATE. The following table describes possible format strings based on different combinations of the first and second arguments. For more information about the specifiers used in the results, see DATE_FORMAT.
| Function call | Result |
|---|---|
| GET_FORMAT(DATE,'USA') | '%m.%d.%Y' |
| GET_FORMAT(DATE,'JIS') | '%Y-%m-%d' |
| GET_FORMAT(DATE,'ISO') | '%Y-%m-%d' |
| GET_FORMAT(DATE,'EUR') | '%d.%m.%Y' |
| GET_FORMAT(DATE,'INTERNAL') | '%Y%m%d' |
| GET_FORMAT(DATETIME,'USA') | '%Y-%m-%d %H.%i.%s' |
| GET_FORMAT(DATETIME,'JIS') | '%Y-%m-%d %H:%i:%s' |
| GET_FORMAT(DATETIME,'ISO') | '%Y-%m-%d %H:%i:%s' |
| GET_FORMAT(DATETIME,'EUR') | '%Y-%m-%d %H.%i.%s' |
| GET_FORMAT(DATETIME,'INTERNAL') | '%Y%m%d%H%i%s' |
| GET_FORMAT(TIME,'USA') | '%h:% I :%s %p' |
| GET_FORMAT(TIME,'JIS') | '%H:%i:%s' |
| GET_FORMAT(TIME,'ISO') | '%H:%i:%s' |
| GET_FORMAT(TIME,'EUR') | '%H.%i.%s' |
| GET_FORMAT(TIME,'INTERNAL') | '%H%i%s' |
| GET_FORMAT(TIMESTAMP,'USA') | '%Y-%m-%d %H.%i.%s' |
| GET_FORMAT(TIMESTAMP,'JIS') | '%Y-%m-%d %H:%i:%s' |
| GET_FORMAT(TIMESTAMP,'ISO') | '%Y-%m-%d %H:%i:%s' |
| GET_FORMAT(TIMESTAMP,'EUR') | '%Y-%m-%d %H.%i.%s' |
| GET_FORMAT(TIMESTAMP,'INTERNAL') | '%Y%m%d%H%i%s' |
Examples
obclient> SELECT DATE_FORMAT('2003-10-03',GET_FORMAT(DATE,'EUR'));
+--------------------------------------------------+
| DATE_FORMAT('2003-10-03',GET_FORMAT(DATE,'EUR')) |
+--------------------------------------------------+
| 03.10.2003 |
+--------------------------------------------------+
1 row in set
obclient> SELECT STR_TO_DATE('10.31.2003',GET_FORMAT(DATE,'USA'));
+--------------------------------------------------+
| STR_TO_DATE('10.31.2003',GET_FORMAT(DATE,'USA')) |
+--------------------------------------------------+
| 2003-10-31 00:00:00.000000 |
+--------------------------------------------------+
1 row in set