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.
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!