美文网首页
Mysql函数()日期时间

Mysql函数()日期时间

作者: 阿登20 | 来源:发表于2019-02-20 19:00 被阅读8次

日期时间函数

  • curdate() 查看当前日期
    select curdate();


    image.png
  • curtime() 查看当前时间
    select curtime();


    image.png
  • 查看当前日期和时间
    select curtime(),curdate();


    image.png
  • 用字符串函数将当前日期和时间合并起来,用空格连接
    select concat (curdate(),' ',curtime())


    image.png
  • now() 返回当前日期和时间
    select now();


    image.png
  • month()返回日期当中的月份
    select month('2019-02-20 18:00:15')
    select month(curdate())


    image.png
  • monthname(日期)返回日期月份英文名
    select monthname(curdate());
    select monthname(now());


    image.png
  • day(日期)返回日期是多少号
    select day(curdate());
    select day('2019-02-20')


    image.png
  • dayofweek(日期)返回日期是星期几,格式1-7 1星期日,2星期一
    select dayofweek('2019-02-20 18:00:15')


    image.png
  • dayname(日期) 返回星期几 英文Monday,Tuesday
    select dayname('2019-02-20 18:00:15')


    image.png
  • week(日期) 计算日期d是本年的第几个星期,范围是0->53
    select week('2019-02-20 18:00:15');
    select week(curdate());


    image.png
  • dayofyear(日期)日期D在本年第多少天
    select dayofyear('2019-011-20 18:00:15');


    image.png
  • dayofmonth(日期) 计算日期d是本月的第几天
    select dayofmonth('2019-02-20 18:00:15');


    image.png
  • minute(时间) 返回T 分钟的值
    select minute('2019-011-20 18:08:15');


    image.png
  • hour(时间) 返回时间小时的 值
    select hour('18:08:15')


    image.png
  • second(时间) 返回时间秒的 值
    select second('18:08:15');


    image.png

相关文章

网友评论

      本文标题:Mysql函数()日期时间

      本文链接:https://www.haomeiwen.com/subject/jlckyqtx.html