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
 Transact-SQL (2005)
 SQL Query

Author  Topic 

sql_user1
Starting Member

1 Post

Posted - 2011-06-13 : 11:46:03
i need to select some data that the enddate is = to todays date and 30 days ahead at any one time. What query would I need for this. The sql I have is below.

SELECT column a,surname,enddate from table c
inner join table p
on c.column=p.columnType
inner join event e
on c.columnid=e.columnid
where
e.typeid=1 and group by c.columnid, column a, column b

Many thanks in advance.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-13 : 11:59:38
and enddate between GETDATE() and GETDATE()+30
or maybe
and enddate between dateadd(dd,datediff,dd,0,GETDATE()),0) and dateadd(dd,datediff,dd,0,GETDATE()),0)+30


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -