current_date()只显示的是当前时间的日期
例如:select current_date() from a ;结果:2021-08-25
current_time()只显示当前时间的时分秒
例如:select current_time() from a ;14:07:06
now()显示全部
例如:select now() from a ;结果:2021-08-25 14:07:56
在增加减少日期时current_time,current_date()类似与now()不同详细如下: current_date()函数
#获取当前日期select current_date() as newdate; #2021-05-20#当前日期加1天(其他天数方法一样)select date_add(current_date(), interval 1 day) as newdate; #2021-05-21#当前日期减1天select date_add(current_date(), interval -1 day) as newdate; #2021-05-19#当前日期加1个月select date_add(current_date(), interval 1 month) as newdate; #2021-06-20#当前日期减1个月select date_add(current_date(), interval -1 month) as newdate; #2021-04-20#当前日期加1年select date_add(current_date(), interval 1 year) as newdate; #2022-05-20#当前日期减1年select date_add(current_date(), interval -1 year) as newdate; #2020-05-20#指定日期加1天(可将day换为month,year来实现加1个月,1年)select date_add('2021-05-20', interval 1 day) as newdate; #2021-05-21#指定日期减1天(可将day换为month,year来实现减1个月,1年)select date_add('2021-05-20', interval -1 day) as newdate; #2021-05-19#当前时间添加1小时10分钟10秒钟select date_add(now(), interval '1:10:10' hour_second) as newtime; #2021-05-20 15:59:32#指定时间添加1小时10分钟10秒钟select date_add('2019-04-17 2:00:00', interval '1:10:10' hour_second) as newtime; #2021-04-17 03:10:10
now()函数
#获取当前时间select now() as newtime; #2021-05-20 14:28:41#当前时间减30秒select (now() - interval 30 second) as newtime; #2021-05-20 14:29:31#当前时间加30秒select (now() + interval 30 second) as newtime; #2021-05-20 14:29:31#当前时间减30分钟select (now() - interval 30 minute) as newtime; #2021-05-20 14:02:26#当前时间加30分钟select (now() + interval 30 minute) as newtime; #2021-05-20 15:02:41#当前时间减1天select (now() - interval 1 day) as newtime; #2021-05-19 14:33:26#当前时间加1天select (now() + interval 1 day) as newtime; #2021-05-21 14:33:33#当前时间减1个月select (now() - interval 1 month) as newtime; #2021-04-20 14:34:10#当前时间加1个月select (now() + interval 1 month) as newtime; #2021-06-20 14:34:47#当前时间减1年select (now() - interval 1 year) as newtime; #2020-05-20 14:35:09#当前时间加1年select (now() + interval 1 month) as newtime; #2022-05-20 14:35:23#指定时间的加减,将上面的now()函数换为指定日期时间即可,以加30分钟为例,如下:select ('2021-05-20 12:30:00' + interval 30 minute) as newtime; #2021-05-20 13:00:00
以上就是mysql中current_time/current_date()与now()区别是什么的详细内容。