Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

query Expand / Collapse
Author
Message
Posted Wednesday, September 18, 2013 11:24 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 12:05 AM
Points: 99, Visits: 304
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.


Post #1496217
Posted Thursday, September 19, 2013 12:14 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 12:47 AM
Points: 7,005, Visits: 8,451
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


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

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


- 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
Post #1496222
Posted Thursday, September 19, 2013 12:58 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 12:05 AM
Points: 99, Visits: 304
Thanks
Post #1496237
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse