Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update Datetime

Author  Topic 

stathis30_2000
Starting Member

23 Posts

Posted - 2007-06-02 : 13:41:06
Hi !

I would like to know how can I update only the time field of a datetime value using SQL.

Thank you.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-02 : 13:49:59
Update as in add/remove a few srcs/mins? You can do that using the DATEADD/DATEDIFF functions. If you can explain more about what you are doing you can get more help..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

stathis30_2000
Starting Member

23 Posts

Posted - 2007-06-02 : 14:23:59
Thank you for your reply. An example would be:

the value 23/09/1923 12:19:12 to become 23/09/1923 00:00:00

What is the query that does this ?

Thank you
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-03 : 01:24:48
[code]
update t
set datecol = dateadd(day, datediff(day, 0, datecol), 0)
from yourtable t
[/code]


KH

Go to Top of Page
   

- Advertisement -