|
-
There are a few different ways to do this. Here to me is the most direct way:
UPDATE InternetTracking_Data.dbo.tblCallCharges
SET StartTime = DATEADD(day, DATEDIFF(day, StartTime, getdate()), StartTime)
The inner part:
DATEDIFF(day, StartTime, getdate())
finds the number of days between the StartTime date and today's date. Then, the DATEADD function simply adds this number of days back to the StartTime, which in effect updates StartTime to today's date while preserving the time element. BTW, if you use this method, you shouldn't have to use the WHILE loop. One UPDATE statement should be all you need.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|