函数 |
用法 |
YEAR(date)/MONTH(date)/DAY(date) |
返回具体的日期值 |
HOUR(time)/MINUTE(time)/SECOND(time) |
返回具体的时间值 |
MONTHNAME(date) |
返回月份:January,…… |
DAYNAME(date) |
返回星期几:MONDAY,TUESDAY……SUNDAY |
WEEKDAY(date) |
返回周几,注意,周一是0,周二是1,……周日是6 |
QUARTER(date) |
返回日期对应的季度,范围1~4 |
WEEK(date),WEEKOFYEAR(date) |
返回一年中的第几周 |
DAYOFYEAR(date) |
返回日期是一年中的第几天 |
DAYOFMONTH(date) |
返回日期位于所在月份的第几天 |
DAYOFWEEK(date) |
返回周几,注意:周日是1,周一是2……周六是7 |
SELECT YEAR(CURDATE()),MONTH(CURDATE()),DAY(CURDATE()),
HOUR(CURTIME()),MINUTE(NOW()),SECOND(SYSDATE())
FROM DUAL;
SELECT MONTHNAME('2021-10-26'),DAYNAME('2021-10-26'),WEEKDAY('2021-10-26'),
QUARTER(CURDATE()),WEEK(CURDATE()),DAYOFYEAR(NOW()),
DAYOFMONTH(NOW()),DAYOFWEEK(NOW())
FROM DUAL;