February 12, 2007 at 3:40 pm
Hello,
Is there a way to update only the time part of a datetime field? For example, changing
02/12/2007 5:30 PM
to
02/12/2007 9:30 PM
I'm thinking of a query such as
UPDATE schedule
SET HOUR(start_time) = 9
WHERE HOUR(start_time) = 5
AND class_id = 100
In other words, even if the class meets for 15 different days at the same time each day, is there a way to change only the time part without worrying about whatever day it is?
Thanks for any help. And let me know if I'm missing something painfully obvious.
Sincerely,
webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
February 12, 2007 at 4:41 pm
Use Dateadd...
UPDATE schedule
SET start_time = DATEADD(hh, 4, start_time)
WHERE DATEPART(hh, start_time) = 5
AND class_id = 100
February 13, 2007 at 7:20 am
Thank you!
webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy