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)
 Need help with SQL statement

Author  Topic 

CXXXV
Starting Member

12 Posts

Posted - 2009-09-03 : 14:24:05
Please look at this statement:

SELECT MEMBERS.LAST_NAME, MEMBERS.FIRST_NAME, PROGRAM_PARTICIPANTS.SUB_PROG_ID, PROGRAM_PARTICIPANTS.MEMBER_ID, MEMBERS.EMAIL, MAX(PROGRAM_PARTICIPANTS.END_DATE) as EXPIRATION
FROM MEMBERS INNER JOIN PROGRAM_PARTICIPANTS ON MEMBERS.MEMBER_ID = PROGRAM_PARTICIPANTS.MEMBER_ID
WHERE (PROGRAM_PARTICIPANTS.SUB_PROG_ID = 0) AND (MEMBERS.CLIENT_ID IS NULL) AND (NOT MEMBERS.EMAIL IS NULL)
group by MEMBERS.LAST_NAME, MEMBERS.FIRST_NAME, PROGRAM_PARTICIPANTS.SUB_PROG_ID, PROGRAM_PARTICIPANTS.MEMBER_ID, MEMBERS.EMAIL


What I need is to add a condition that in addition to all that will return only those records where the EXPIRATION value is less than TODAY.

Tx.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-09-03 : 14:34:12
and EXPIRATION < dateadd(day,datediff(day,0,getdate()),0)

That knocks the time piece off of getdate()

Jim
Go to Top of Page

CXXXV
Starting Member

12 Posts

Posted - 2009-09-03 : 14:44:29
Tx. Got it.
Go to Top of Page
   

- Advertisement -