Home > Database > Mysql Tutorial > body text

What is the mysql format function?

coldplay.xixi
Release: 2020-06-29 15:30:23
Original
3794 people have browsed it

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template