zoukankan      html  css  js  c++  java
  • SQL Server 2014如何DATEDIFF()函数截取对应时间年月日

    4.1 定义和用法: DATEDIFF()函数返回两个日期之间的时间

    4.2 语法

          DATEDIFF(datepart,startdate,enddate)

          datepart: year | quarter | month | week | day | hour | minute | second

          startdate:开始日期

          enddate:结束日期

         GetDate()获取系统当前时间

     4.3  DATEDIFF截取时间示例

            查询今天
            SELECT * FROM tablename where DATEDIFF(day,inputdate,GETDATE())=0


        查询昨天
            SELECT * FROM tablename where DATEDIFF(day,inputdate,GETDATE())=1


        查询本周
             SELECT * FROM tablename where datediff(week,inputdate,getdate())=0


        查询上周
             SELECT * FROM tablename where datediff(week,inputdate,getdate())=1


        查询本月
             SELECT * FROM tablename where DATEDIFF(month,inputdate,GETDATE())=0


        查询上月
             SELECT * FROM tablename where DATEDIFF(month,inputdate,GETDATE())=1

  • 相关阅读:
    xml ui
    xml ui
    xml ui
    debug
    centOS7 mini配置linux服务器(一)安装centOs7
    数据结构之__链表
    数据结构之__队列
    数据结构之__栈
    在树莓派上使用 SSD1306 OLED 屏幕
    git官方手册
  • 原文地址:https://www.cnblogs.com/lcl-cn/p/13871245.html
Copyright © 2011-2022 走看看