dayofweek(date):返回日期date的星期索引(1=星期天,2=星期一,....,7=星期六)。
select dayofweek('1998-02-03')
->3
weekday(date):返回date的星期索引(0=星期一,1=星期二,....,6=星期天)
select weekday('1997-10-04 22:23:00');
->5
dayofmonth:返回date的月份中日期,在1~31范围内
select dayofmonth('1998-02-03');
->3
dayofyear(date):返回date在一年中的日数,在1~366范围内
select dayofyear('1998-02-03');
->34
month(date):返回date的月份,范围1~12
select month('1998-02-03');
->2
dayname(date):返回date的星期名字
select dayname('1998-02-05');
->'Thursday'
monthname(date):返回date的月份名字
select monthname('1998-02-05');
-'February'
quarter(date):返回date一年中的季度,范围1~4
select quarter('98-04-01');
->2
week(date):返回date的周数(星期天是一周的第一天),范围0~52
select week('1998-02-20');
->7
week(date,first):如果第二个参数是0,一周从星期天开始。如果第二个参数是1,一周从星期一开始
select wekk('1998-02-20',0);
->7
year(date):返回date的年份,范围在1000~1999
select year('98-02-03');
->1998
hour(time):返回time的小时,范围是0~23
select hour('10:05:03');
->10
minute(time):返回time的分钟,范围是0~59
select minute('98-02-03' 10:05:03');
->5
second(time):返回time的秒数,范围是0~59
select second('10:05:03');
->3
select day(date) as day,
count(question_id) as question_cnt
from question_practice_detail
where month(date)=8 and year(date)=2021
group by date