zoukankan      html  css  js  c++  java
  • SQL查询月、天、周、年(MySql的实例对比)

    SQL Server实现

    日期部分缩写
    year yy, yyyy
    quarter qq, q
    month mm, m
    dayofyear dy, y
    day dd, d
    week wk, ww
    weekday dw
    Hour hh
    minute mi, n
    second ss, s
    millisecond ms
     1  2

    在MySql中实现:

    1——   
     2  本年:   
     3  select   *   from   loanInfo   where   year(date)=year(getdate())   
     4    
     5  2——   
     6  本月:   
     7  select   *   from   loanInfo   where   year(date)=year(getDate())   And   month(date)=month(getdate())   
     8    
     9  3——   
    10  本日:   
    11  select   *   from   loanInfo   where   year(date)=year(getDate())   And   month(date)=month(getdate())   and   Day(date)=Day(getDate())  
    12
    13
    14
    15SELECT   *    FROM   table    WHERE   (MONTH(字段)   =   MONTH(GETDATE()))   

  • 相关阅读:
    【BZOJ1076】[SCOI2008]奖励关 状压DP+期望
    【TYVJ1864】[Poetize I]守卫者的挑战 概率与期望
    【BZOJ1426】收集邮票 期望
    设置SAPgui自动退出功能
    SAP系统联机应用程序帮助
    c++ 类型安全
    生成与重新生成的区别
    2014-02-20
    新公司工作
    落后了
  • 原文地址:https://www.cnblogs.com/nxxshxf/p/5590155.html
Copyright © 2011-2022 走看看