MySQL GET_FORMAT() Function
In MySQL, the GET_FORMAT()
function returns a format string according to arguments. This function is often used in conjunction with DATE_FORMAT()
and STR_TO_DATE()
.
GET_FORMAT()
Syntax
Here is the syntax of MySQL GET_FORMAT()
function:
GET_FORMAT({DATE|TIME|DATETIME}, {'EUR'|'USA'|'JIS'|'ISO'|'INTERNAL'})
Return value
The following table lists all possible return values ββfor MySQL GET_FORMAT()
function.
transfer | 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()
Examples
SELECT
GET_FORMAT(DATE, 'USA'),
GET_FORMAT(DATE, 'JIS'),
GET_FORMAT(DATE, 'ISO'),
GET_FORMAT(DATE, 'EUR'),
GET_FORMAT(DATE, 'INTERNAL'),
GET_FORMAT(TIME, 'USA'),
GET_FORMAT(TIME, 'JIS'),
GET_FORMAT(TIME, 'ISO'),
GET_FORMAT(TIME, 'EUR'),
GET_FORMAT(TIME, 'INTERNAL'),
GET_FORMAT(DATETIME, 'USA'),
GET_FORMAT(DATETIME, 'JIS'),
GET_FORMAT(DATETIME, 'ISO'),
GET_FORMAT(DATETIME, 'EUR'),
GET_FORMAT(DATETIME, 'INTERNAL')\G
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(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(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