数据类型为datetime
startTime
endTime
判断当前日期是否在以上之间?
谢谢啦!

解决方案 »

  1.   

    WHERE startTime <= GetDate()
      AND GetDate() <= endTime
    根据你的之间是否包含边界决定是否需要用 =。
      

  2.   

    if startTime <= GetDate() and   GetDate() <= endTime
    begin
    ...... 你要进行的处理过程
    end
      

  3.   

    GETDATE() BETWEEN startTime  AND ENDTIME
      

  4.   

    declare @sdate datetime = '2014-09-10 22.49:00.000',
                  @edate datetime = '2014-09-11 20:00:00.000'
    if getdate()  between @sdate and @edate
    begin
    ...............
    end
    else
    begin
    ...............
    end
      

  5.   

    datetime类型直接between and 或者用<和>这些,但是datetime要注意每天的结尾时间是23:59:59.997,而不是999
      

  6.   

    如果仅是判断到天,那么用DateDiff 比较保险 DECLARE @StartDate DATETIME='9/10/2014'
    DECLARE @EndDate DATETIME='10/12/2014'
    SELECT 1 FROM tb1 WHERE DATEDIFF(d,@StartDate,GETDATE())>=0 and DATEDIFF(d,GETDATE(),@EndDate)>=0
    -
      

  7.   


    if GETDATE() >=@startTime and GETDATE()<=@endTime
    begin
    end
      

  8.   

    GETDATE() BETWEEN startTime  AND ENDTIME