SQL Server Performance

query

Discussion in 'ALL SQL SERVER QUESTIONS' started by immad, Sep 18, 2013.

  1. immad Member

    i have a query

    UPDATE dbo.cheeck
    SET CheckTime = DATEADD(DAY, -1, CheckTime)
    WHERE Status = 'O' and datepart(hh,CheckTime) BETWEEN 0 AND 11

    i want to update a current date data please help me to resolve this problem.
  2. Shehap MVP, MCTS, MCITP SQL Server

    If I am not wrong in my understanding for your case , you can make use of Date diff function with hour parameter to filter the needed data according to your business needs as follows:

    Code:
    UPDATE dbo.cheeck
    SET CheckTime = DATEADD(DAY, -1, CheckTime)
    WHERE Status = 'O' and DATEDIFF(HOUR,CHEKTIME , GETDATE())<12

Share This Page