- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of MySQL GET_FORMAT() function?
MySQL GET_FORMAT() function is used to convert a datatype like DATE, TIME, DATETIME or TIMESTAMP in a formatted manner based on the standard format given as the second argument. The standard format type may be EUR, INTERNAL, ISO, JIS or USA. The format codes returned are the same codes used by the DATE_FORMAT() function. This function is useful in combination with DATE_FORMAT() and STR_TO_DATE() function.
Syntax
GET_FORMAT(data_type, standard_format)
Here as we told earlier, data_type would be DATE, TIME, DATETIME or TIMESTAMP, and standard_format maybe EUR, INTERNAL, ISO, JIS or USA.
Example
mysql> Select GET_FORMAT(DATE, 'USA') AS 'AMERICAN Format', -> GET_FORMAT(DATE, 'ISO') AS 'ISO Format'; +-----------------+------------+ | AMERICAN Format | ISO Format | +-----------------+------------+ | %m.%d.%Y | %Y-%m-%d | +-----------------+------------+ 1 row in set (0.00 sec)
The query above returns the date format used in USA and ISO Date format.
mysql> Select GET_FORMAT(TIME, 'USA') AS 'AMERICAN Format', -> GET_FORMAT(TIME, 'ISO') AS 'ISO Format'; +-----------------+------------+ | AMERICAN Format | ISO Format | +-----------------+------------+ | %h:%i:%s %p | %H:%i:%s | +-----------------+------------+ 1 row in set (0.00 sec)
The query above returns the time format used in USA and ISO Date format.
- Related Articles
- What is the use of MySQL SUBSTRING_INDEX() function?
- What is the use of MySQL UNHEX() function?
- What is the use of MySQL CHAR() function?
- What is the use of MySQL FROM_UNIXTIME() function?
- What is the use of MySQL LAST_INSERT_ID() function?
- What is the use of MySQL CONCAT_WS() function?
- What is the use of MySQL TRUNCATE() function?
- What is the use of FIND_IN_SET () function in MySQL?
- What is the use of LOCATE() function in MySQL?
- What is the use of MySQL IFNULL() control flow function?
- What is the use of MySQL NULLIF() control flow function?
- How GET_FORMAT() function can combine with DATE_FORMAT() and STR_TO_DATE() function?
- What is the use of JavaScript eval function?
- What is the use of apply() function in JavaScript?
- What is the use of Math.hypot() function in JavaScript?

Advertisements