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 |
|
gavakie
Posting Yak Master
221 Posts |
Posted - 2008-03-24 : 13:37:33
|
| how do i get a column showing the next 30 days? |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-03-24 : 13:48:26
|
| select Convert(varchar(10), MyDate, 101) from (select getdate() + 01 as MyDate union allselect getdate() + 02 as MyDate union allselect getdate() + 03 as MyDate union allselect getdate() + 04 as MyDate union allselect getdate() + 05 as MyDate union allselect getdate() + 06 as MyDate union allselect getdate() + 07 as MyDate union allselect getdate() + 08 as MyDate union allselect getdate() + 09 as MyDate union allselect getdate() + 10 as MyDate union allselect getdate() + 11 as MyDate union allselect getdate() + 12 as MyDate union allselect getdate() + 13 as MyDate union allselect getdate() + 14 as MyDate union allselect getdate() + 15 as MyDate union allselect getdate() + 16 as MyDate union allselect getdate() + 17 as MyDate union allselect getdate() + 18 as MyDate union allselect getdate() + 19 as MyDate union allselect getdate() + 20 as MyDate union allselect getdate() + 21 as MyDate union allselect getdate() + 22 as MyDate union allselect getdate() + 23 as MyDate union allselect getdate() + 24 as MyDate union allselect getdate() + 25 as MyDate union allselect getdate() + 26 as MyDate union allselect getdate() + 27 as MyDate union allselect getdate() + 28 as MyDate union allselect getdate() + 29 as MyDate union all select getdate() + 30 as MyDate union all select getdate() + 31 as MyDate ) a "God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-24 : 14:03:02
|
| or:-SELECT DATEADD(d,number,GETDATE())FROM master..spt_valuesWHERE number BETWEEN 1 AND 31AND type='p' |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-03-24 : 14:25:53
|
Use the date table function from the link below.Date Table Function F_TABLE_DATEhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519declare @start_date datetimedeclare @end_date datetimeselect @start_date = getdate()+1select @end_date = @start_date+30select *from dbo.F_TABLE_DATE ( @start_date, @end_date ) CODO ERGO SUM |
 |
|
|
|
|
|