zoukankan      html  css  js  c++  java
  • mysql 日期函数

    #now(),获取当前时间戳的日期格式['Y-m-d H:i:s']
    #sysdate().获取当前时间戳的日期格式['Y-m-d H:i:s']
    select now()
    select sysdate();
    
    #curdate() 获取当前时间戳的日期格式['Y-m-d']  current_date()
    select curdate();
    select current_date();
    
    #curtime()/current_time 获取当前时间戳的时间格式['H:i:s']
    select curtime();
    select current_time();
    
    # 获得当前 UTC(格林尼治时间) 日期时间函数:utc_date(), utc_time(), utc_timestamp()
    select utc_time(),utc_date(),utc_timestamp()
    
    #dayofweek(date)获取日期一周中属于周几
    #dayofmonth()获取日期在一月中属于第几天
    #dayofyear()获取日期在一年中属于第几天
    select dayofweek('2014-11-17')
    select dayofmonth('2014-11-17')
    select dayofyear('2014-11-17')
    
    #5. MySQL 返回星期和月份名称函数:dayname(), monthname()
    select dayname();
    select monthname();
    
    #last_day()返回日期月份中最后一天的日期
    select last_day('2014-11-17');
    
    #date_add(now(),sss)返回一个增加设定的日期
    select date_add('2014-11-17',interval 2 day) 
    select date_add('2014-11-17',interval 1 week) 
    
    #date_sub(now(),sss) 返回一个减少特定设定的日期
    select date_sub('2014-11-17',interval 2 day)
    
    #period_diff(date1,date2)比较两个日期相差的月数
    period_diff(201411,201408);
    
    #unix_timestamp()获取当前的时间戳
    select unix_timestamp();
    
    #from_unixtime()将时间戳转化为日期格式
    select from_unixtime(unix_timestamp(),'%Y-%m-%d');
    
    #date_format格式化日期格式
    select date_format(now(),'%Y-%m-%d');
    

      

  • 相关阅读:
    其他技术----mongoDB基础
    redis学习----Redis入门
    网络通信学习----HTTP请求方法
    spring boot 学习 ---- spring boot admin
    java拓展----(转)synchronized与Lock的区别
    spring boot 学习 ---- spring MVC
    解决ubuntu的apt-get命令被占用
    阴暗
    图像分割实战-视频背景替换
    「知乎」你们觉得响应式好呢,还是手机和PC端分开来写?
  • 原文地址:https://www.cnblogs.com/ikasa007/p/4103600.html
Copyright © 2011-2022 走看看