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)
 Subtracting from a date

Author  Topic 

miked1978
Starting Member

25 Posts

Posted - 2009-01-13 : 12:55:09
I have a column named Date in my table which shows varoius Sundays (ex: 1/11/2009)but I want to subtract 6 days from it to show the previous Monday. So I want 1/11/2009 to change to 1/05/2009 and so forth.

Is there and update statement or and alter statement I can use?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-13 : 12:57:17
yup.just use

UPDATE Table
SET Date=Date-6
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-13 : 12:58:00
or even dateadd

UPDATE Table
SET Date=DATEADD(dd,-6,Date)


Go to Top of Page
   

- Advertisement -