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)
 changing info in a column

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-05-27 : 14:47:49
I need to run a stored procedure again but need to switch the date from 5/22/2009 to 5/15/2009 before I run it. How do I write a small query to do this?

The field is called week_start_date (datetime, null)

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-05-27 : 15:41:26
Your question is way too ambiguous. What do you mean by "need to switch date"? Are you trying to pass a parameter to a stored proc?

Some days you're the dog, and some days you're the fire hydrant.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-05-27 : 15:46:57
I have to agree with Skorch, that we need more info. But, maybe this will help?
UPDATE MyTable
SET week_start_date = '20090515'
WHERE week_start_date = '20090522'
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-05-28 : 09:13:12
Sorry for being vague but this worked:

UPDATE CurrentDiary
SET week_start_date = '20090515'
WHERE (week_start_date = '20090522')

I just needed to change the date from one date to the next. Thanks!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-28 : 11:50:07
if its for single update you can hardcode like this. but if your attempt is just to change all date values by a week backwards, simply do

UPDATE CurrentDiary
SET week_start_date =DATEADD(wk,-1, week_start_date )


rather than hardcoding each date
Go to Top of Page
   

- Advertisement -