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;

 

posted @   langpo  阅读(75)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
点击右上角即可分享
微信分享提示