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
 .NET Inside SQL Server (2005)
 Add Days to the Given date

Author  Topic 

Anjani
Starting Member

2 Posts

Posted - 2010-03-25 : 07:36:00
Hi,

I like to get the seven dates from the given date.

IF i enetered the date as 1/03/2010 it must give the next sixdays dates i.e.

2/03/2010,3/03/2010....7/03/2010

Please tell me how i can do this in sqlserver 2005



Anjani

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-03-25 : 07:51:31
Maybe just this?

DECLARE @foo DATETIME

SET @foo = GETDATE()

SELECT
@foo AS CurrentDAte
, DATEADD(DAY, 1, @foo) AS [Plus1]
, DATEADD(DAY, 2, @foo) AS [Plus2]
, DATEADD(DAY, 3, @foo) AS [Plus3]
, DATEADD(DAY, 4, @foo) AS [Plus4]
, DATEADD(DAY, 5, @foo) AS [Plus5]
, DATEADD(DAY, 6, @foo) AS [Plus6]




Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

umstorom
Starting Member

6 Posts

Posted - 2010-05-14 : 04:02:57
work for me, thanks!

http://www.developerbay.net
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-14 : 13:17:20
this will generate you whole set of date values between start and end

http://visakhm.blogspot.com/2010/02/generating-calendar-table.html

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

Go to Top of Page
   

- Advertisement -