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
 General SQL Server Forums
 New to SQL Server Programming
 datetime problem

Author  Topic 

Asdzxc1986
Starting Member

14 Posts

Posted - 2009-12-19 : 14:00:13
Hi.

I need to change date, without changing the time.

Example:

29.12.1899 22:34:00 need to change on

30.12.1899 22:34:00

update d_route set time = ? where oper_id=0

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-19 : 14:05:53
update d_route
set time = DATEADD(dd, 1, time)
where oper_id=0


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Asdzxc1986
Starting Member

14 Posts

Posted - 2009-12-19 : 14:32:14
I have a table with hungred rows of data. All oh them are different. How can I change column time? I need change only date part, with saving time part?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-19 : 14:35:45
That's what that query does.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Asdzxc1986
Starting Member

14 Posts

Posted - 2009-12-19 : 15:01:06
I have column TIME. In that column I have different values like:
29.12.1899 22:34:00
29.12.1899 21:34:00
29.12.1899 20:34:00
29.12.1899 19:34:00

I need to change that values on

30.12.1899 22:34:00
30.12.1899 21:34:00
30.12.1899 20:34:00
30.12.1899 19:34:00

I dont understand how to take time part from '29.12.1899 19:34:00' and put it into time place?

update d_route
set time = DATEADD('30.12.1899', 1, ?)
where oper_id=0
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-19 : 15:39:52
No, just run my UPDATE statement. It does what you want. It simply adds one day to the existing data.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -