SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Update a date column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rama.nelluru
Starting Member

USA
35 Posts

Posted - 10/27/2011 :  21:33:40  Show Profile  Reply with Quote
Hi ,

I need to write a script that updates the date columns.

My requirement is

I have date column

Col name-----Datecol
01-10-2010
01-17-2010
01-24-2010.......with a week diffrnce

I need to update 01-10-2010 with the 04-06-2010
01-10-2010 with the 04-13-2010( a week diffrence hear)

so finally the first date(01-10-2010) must be update with 04-06-2010...a week diffrnce in both the dates....
I need to channge like 12 weeks like that.

Please help me on this....



RAM

X002548
Not Just a Number

15586 Posts

Posted - 10/27/2011 :  22:41:22  Show Profile  Reply with Quote
look up dateadd in Books online...you do know what bol is?


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/28/2011 :  05:36:59  Show Profile  Reply with Quote
see this at least if you cant refer bol

http://msdn.microsoft.com/en-us/library/ms186819.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rama.nelluru
Starting Member

USA
35 Posts

Posted - 10/28/2011 :  08:36:52  Show Profile  Reply with Quote
I have table with column name datecol data
-------
01-10-2010
01-17-2010
01-24-2010

and in other table or same table i have datecolumn with data
04-10-2012
04-17-2012
04-24-2012

I want update if 01-10-2010 was the date i need to update with 04-10-2012
if 01-17-2010 was the date i need to update with 04-10-2012
like that i need to update foe 10 continous weeks.

Please some one can help me to write a script that updates the date with 1 week diffrence in the tables column.

RAM

Edited by - rama.nelluru on 10/28/2011 08:38:45
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/28/2011 :  08:42:34  Show Profile  Reply with Quote
one question. how do you determine which date in your first table needs to replaced by which date in other table? do you have a common field with which you can relate them?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 10/28/2011 :  09:53:50  Show Profile  Reply with Quote
DATEDIFF(dd, DAtecol, Getdate()) < 10

???

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

rama.nelluru
Starting Member

USA
35 Posts

Posted - 10/28/2011 :  11:46:37  Show Profile  Reply with Quote
common field is weekid. How do I update the teh date. Please any someone can help me out the script

RAM
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 10/28/2011 :  11:57:30  Show Profile  Reply with Quote
quote:
Originally posted by rama.nelluru

common field is weekid. How do I update the teh date. Please any someone can help me out the script

RAM



Sure, Read my link in my sig, or Post the DDL, some sample Data in DML Form and what the expected results are suppose to be...

If that's too much work, well, then...good luck

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/28/2011 :  12:27:03  Show Profile  Reply with Quote
quote:
Originally posted by rama.nelluru

common field is weekid. How do I update the teh date. Please any someone can help me out the script

RAM


can we see what update query you tried and what was issue you faced with it?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.5 seconds. Powered By: Snitz Forums 2000