47.日期函数
now 返回现在时间+日期
select(now)
select year(now()) 年;\month,day时间
select year(具体时间);
curedate 返回当前日期,不包含日期
slect curedate();
now: 获取当前日期
str_to_date:将日期格式的字符专换成只当格式的日期
格式符 功能
1 %Y 4位的年份
2 %y 2位的年份
3 %m 月份(01,02,03,...12)
4 %c 月份(1,2)
5 %d 日(01,02....)
6 %H 小时(24小时)
7 %h 小时(12小时)
8 %i 分钟(00.01.。。。)
9 %s 秒(00,01...)
str_to_date 将字符通过指定格式转换成日期
select str_to_date(1998-3-2','% ,y-%c-%d') as out_put;
date_format:将日期转换成字符
select date_format(now(),"%y年%m月%d日) as out_put;
查询有奖金的员工名和入职日期(xx月/xx日 xx年)
select lat_name,date_format(hiredate,‘%m月/%d日 %y年’)
from employee where commission_id is not null;

浙公网安备 33010602011771号