MariaDB GET_FORMAT() Function
In MariaDB, GET_FORMAT()
is a built-in function that returns a formatted string according to the parameters.
GET_FORMAT()
is often used with the DATE_FORMAT()
or STR_TO_DATE()
function.
MariaDB GET_FORMAT()
Syntax
This is the syntax of the MariaDB GET_FORMAT()
function:
GET_FORMAT({DATE|TIME|DATETIME}, {'EUR'|'USA'|'JIS'|'ISO'|'INTERNAL'})
Return value
The following table lists all possible return values โโof the MariaDB GET_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' |
MariaDB GET_FORMAT()
Examples
This statement shows the usage of the MariaDB GET_FORMAT()
function:
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
Output:
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
Conclusion
In MariaDB, GET_FORMAT()
is a built-in function that returns a formatted string according to the parameters.