Home >Database >Mysql Tutorial >How to convert mysql date format to number format

How to convert mysql date format to number format

藏色散人
藏色散人Original
2023-02-13 10:10:154252browse

How to convert mysql date format to digital format: 1. Check the date that needs to be converted; 2. By executing "SELECT DATE_FORMAT(Now(),'%Y%m%d%H%i%s' ) FROM test;" command can convert the date format into the digital format of YYYYMMDD.

How to convert mysql date format to number format

The operating environment of this tutorial: Windows 10 system, mysql5.5 version, Dell G3 computer.

How to convert mysql date format to numeric format?

Convert the date format to the digital form of YYYYMMDD in mysql

SELECT DATE_FORMAT(Now(),'%Y%m%d%H%i%s') FROM test;
%Y%m%d%H%i%s 年月日时分秒
%Y%m%d 对应 YYYYMMDD

Example:

How to convert mysql date format to number format

Related extensions:

DATE_FORMAT() function is used to display date/time data in different formats.

Syntax

DATE_FORMAT(date,format)

The date parameter is a legal date. format specifies the date/time output format.

The formats that can be used are:

##%eDay of the month, value (0-31)% fMicroseconds##%H%h%I%i %j%k%l%M%m%p%r%S%s%T%U%u%V# with %X ##%vweek(01-53) Monday is the first day of the week, and %x uses %Wweek Name%wDay of the week (0=Sunday, 6=Saturday)%X year, where Sunday is the first day of the week, 4 digits, and %V use %x year, where Monday is the first day of the week One day, 4 digits, with %v using %Y Year, 4 digits%y年, 2 places Recommended study: "MySQL Video Tutorial
Format Description
%a Abbreviated week name
%b Abbreviated month name
%c Month, Value
%D Day of the month with English prefix
%d of the month Day, value (00-31)
hour(00-23)
hour(01-12)
hour(01-12)
Minute, value (00-59)
Day of the year (001-366)
hours(0-23)
hours(1-12)
Month name
Month, value (00-12)
AM or PM
Time, 12-hour (hh:mm:ss AM or PM )
seconds (00-59)
seconds (00 -59)
Time, 24-hour (hh:mm:ss)
week(00-53) Sunday is the first day of the week
week(00-53) Monday is the first day of the week Day
Week (01-53) Sunday is the first day of the week, use
"

The above is the detailed content of How to convert mysql date format to number format. 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