query

  • 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.

    immad

  • immaduddinahmed (9/18/2013)


    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.

    I'm not sure if I understand your question.

    If you are trying to only update the data for today (current date), just add the cryterium.

    Declare @DateFrom datetime , @DateTo datetime

    /* convert datetime to date 00:00:00.000 */

    Set @DateFrom = dateadd(dd, datediff(dd, 0, getdate() ),0)

    Set @DateTo = Dateadd(HH, 12, @DateFrom)

    UPDATE dbo.cheeck

    SET CheckTime = DATEADD(DAY, -1, CheckTime)

    WHERE Status = 'O' /*and datepart(hh,CheckTime) BETWEEN 0 AND 11 --> not needed because we filter checktime from / to */

    AND checktime >= @DateFrom

    and checktime < @DateTo

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Thanks

    immad

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply