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.
| Author |
Topic |
|
smithani
Starting Member
42 Posts |
Posted - 2007-09-11 : 22:11:40
|
| Hi All,I need to do this.For ex:'2007-02-28' is the firstdate I haveand 02-28-2007 is a Wednesday..I need the nextdate to be a Wednesday and for next yearlike 02-27-2008 which is also a wednesday.so far I have this much.but I am stuckdeclare @firstdate datetime,@newdate datetimeset @firstdate ='2007-02-28'set @newdate=dateadd(mm, 12, @nextdate)select @newdateselect datename(dw,@firstdate) as oneselect datename(dw,@newdate) as twoHow do i proceed from here.Thanks for any input |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-09-11 : 22:22:52
|
[code]DECLARE @firstdate datetime, @newdate datetimeSELECT @firstdate = '2007-02-28', @newdate = DATEADD(week, 52, @firstdate)SELECT firstdate = @firstdate, firstdate_wd = DATENAME(weekday, @firstdate), newdate = @newdate, newdate_wd = DATENAME(weekday, @newdate)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|