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)
 In where Clause

Author  Topic 

irfanshirur
Starting Member

21 Posts

Posted - 2009-09-03 : 05:48:20

Hi

Can any one tell me how we can use the this perticuler secenario in where CLause

Based on if(PPSD.Responsibility_Type_Code =1 )
{
//then i want this condition to append in where clause

AND ( C.Originial_Submission_Date <='9/3/2009 12:03:57 PM') and
((DATEDIFF(DD, C.Originial_Submission_Date ,'9/3/2009') >= 0 ) and
(DATEDIFF(DD, C.Originial_Submission_Date ,'9/3/2009') <=30))
}

else this perticuler condition in Where clause
{
AND ( CSD.Claim_Submission_Date <='9/3/2009 12:03:57 PM') and
((DATEDIFF(DD, CSD.Claim_Submission_Date ,'9/3/2009') >= 0 ) and
(DATEDIFF(DD, CSD.Claim_Submission_Date ,'9/3/2009') <=30))

}


Please let me know if any one have any idea how we can go ahead with thes kind of scenario.

Thanks
Regards
Mohammed Irfan

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-03 : 06:04:30
where

(
(PPSD.Responsibility_Type_Code =1 )
and
{

AND ( C.Originial_Submission_Date <='9/3/2009 12:03:57 PM') and
((DATEDIFF(DD, C.Originial_Submission_Date ,'9/3/2009') >= 0 ) and
(DATEDIFF(DD, C.Originial_Submission_Date ,'9/3/2009') <=30))
}
or

{
( CSD.Claim_Submission_Date <='9/3/2009 12:03:57 PM') and
((DATEDIFF(DD, CSD.Claim_Submission_Date ,'9/3/2009') >= 0 ) and
(DATEDIFF(DD, CSD.Claim_Submission_Date ,'9/3/2009') <=30))

)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-03 : 06:05:39
Try this

where
(PPSD.Responsibility_Type_Code =1 AND
( C.Originial_Submission_Date <='9/3/2009 12:03:57 PM') and
((DATEDIFF(DD, C.Originial_Submission_Date ,'9/3/2009') >= 0 ) and
(DATEDIFF(DD, C.Originial_Submission_Date ,'9/3/2009') <=30)) )
OR
( CSD.Claim_Submission_Date <='9/3/2009 12:03:57 PM') and
((DATEDIFF(DD, CSD.Claim_Submission_Date ,'9/3/2009') >= 0 ) and
(DATEDIFF(DD, CSD.Claim_Submission_Date ,'9/3/2009') <=30))



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-03 : 06:06:10



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -