mysql时间函数之year,quarter,month,week⽤法
YEAR(date)
Returns the year for date, in the range 1000 to 9999, or 0 for the “zero” date.
返回⽇期的年份,范围为1000到9999,或者对于“零”⽇期返回0。
QUARTER(date)
Returns the quarter of the year for date, in the range 1 to 4.
返回⽇期的⼀年中的季度,范围为1到4。
MONTH(date)
Returns the month for date, in the range 1 to 12 for January to December, or 0 for dates such as ‘0000-00-00’ or ‘2008-00-00’ that have a zero month part.
返回⽇期的⽉份,1⽉⾄12⽉的范围为1⾄12,对于包含⽉份为零的⽇期(如“0000-00-00”或“2008-00-00”),返回0。
谭冠三
WEEK(date[,mode])
毛毯怎么洗This function returns the week number for date. The two-argument form of WEEK() enables you to specify whether the week starts on Sunday or Monday and wh
怀念战友原唱此函数返回⽇期的周号。 WEEK()的双参数使您能够指定星期是从星期天还是星期⼀开始,以及返回值是在0到53还是从1到53的范围
内。如果省略mode参数,则值 使⽤了default_week_format系统变量。
实例
清蒸鲟鱼的做法
千古名句SELECT YEAR('2011-12-13'); # 2011
SELECT QUARTER('2011-12-13'); # 4
SELECT MONTH('2011-12-13'); # 12
云南录取分数线SELECT WEEK('2011-12-31'); # 52
SELECT WEEK('2004-12-31',0); # 52
小人国故事SELECT WEEK('2004-12-31',1); # 53
SELECT WEEK('2004-01-01',0); # 0
黑桃7SELECT WEEK('2004-01-01',1); # 1