Home >Database >Mysql Tutorial >What is the mysql format function?

What is the mysql format function?

coldplay.xixi
coldplay.xixiOriginal
2020-06-29 14:49:123852browse

Mysql formatting function is: 1. [DATE_FORMAT(date,fmt)] formats the date value according to the string fmt; 2. [FORMAT(x,y)] formats x as separated by commas Open digital sequence, y is the number of decimal places; 3. [INET_ATON(ip)] returns the IP address.

What is the mysql format function?

mysql format function is:

1, DATE_FORMAT(date,fmt) : Format the date value according to the string fmt.

2, FORMAT(x,y): Format x into a sequence of numbers separated by commas, y is the number of decimal places in the result.

3, INET_ATON(ip): Returns the numerical representation of the IP address.

4, INET_NTOA(num): Returns the IP address represented by the number.

5, TIME_FORMAT(time,fmt): Format the time value according to the string fmt.

The simplest of them is the FORMAT() function, which can format large numerical values ​​into an easy-to-read sequence separated by commas.

Example:

SELECT FORMAT(34234.34323432,3);
SELECT DATE_FORMAT(NOW(),'%W,%D %M %Y %r');
SELECT DATE_FORMAT(NOW(),'%Y-%m-%d');
SELECT DATE_FORMAT(19990330,'%Y-%m-%d');
SELECT DATE_FORMAT(NOW(),'%h:%i %p');
SELECT INET_ATON('10.122.89.47');
SELECT INET_NTOA(175790383);

Related learning recommendations: mysql video tutorial

The above is the detailed content of What is the mysql format function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn