Home >Database >Mysql Tutorial >How to use YEAR function in MySQL

How to use YEAR function in MySQL

王林
王林forward
2023-06-03 23:21:341581browse

YEAR(date)

SELECT YEAR(‘70-01-16') 
SELECT YEAR(‘2070-01-16') 
SELECT YEAR(‘69-01-16 00:00:00')
-> 1970 (表示返回date的4位数年份)
-> 2070 
-> 1969

It should be noted that if the year has only two digits, the automatic completion mechanism is based on the default time of 1970.01.01, > ;= Completion of 70 19, < Completion of 70 20

The above is the detailed content of How to use YEAR function in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete