Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Dates

Status
Not open for further replies.

glewis1636

Programmer
Apr 26, 2004
39
US
I have a table with a date column. I would like to randomly update those dates that fall within a certain range to a new date within another range...

for example, all dates that fall before 8/1/05 changed to some date in the range 11/15/05 to 11/15/06.

Any ideas?
 
Code:
DECLARE @seed INT
SET @seed = 7
UPDATE MyTable SET
   col_dates = DATEADD(day, FLOOR(RAND(@seed)*365), '11/15/05')
WHERE DATEDIFF(day, col_dates, '8/15/05') > 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top