mysql获取当前年月

//1.获取年月日 时分秒 

select SYSDATE() AS '年月日 时分秒';
2020-07-02 16:36:17
//2.获取(年月日)

select DATE(CURDATE()) as '年月日';
select CURDATE() as '年月日';
select current_date AS '年月日';
 
2020-07-02
//3.获取(时分秒):

select time(SYSDATE()) AS '时分秒';
select CURtime() AS '时分秒';

16:36:17
//4.获取年份

select YEAR(CURDATE()) AS '';
select YEAR(SYSDATE()) AS '';
select year(CURRENT_DATE) AS '' ;
 
2020
//5.获取月份

select MONTH(CURDATE()) AS '';
select MONTH(SYSDATE()) AS '';
select month(CURRENT_DATE) AS '';

7
//6.获取日期中的日 

select day(CURRENT_DATE) AS '';
select day(CURDATE) AS '';
select day(SYSDATE) AS '';

3
//7.获取当年一月份

select CONCAT(YEAR(CURDATE()),'-','01');
 
2020-07
//8.获取当前系统小时:

select HOUR(SYSDATE()) AS '系统小时';

16
//9.获取当前系统分钟:

select MINUTE(SYSDATE()) AS '系统分钟';

36
//10.获取当前系统秒:

select SECOND(SYSDATE()) AS '系统秒';

17
//11.获取当前系统毫秒:
select MICROSECOND(SYSDATE()) AS '系统毫秒';
0

 

posted @ 2022-06-19 22:33  花田007  阅读(8608)  评论(0编辑  收藏  举报