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 |
|
cajay
Starting Member
2 Posts |
Posted - 2012-08-10 : 16:18:47
|
| Can someone please help me refine this query so that I am able to parse multiple date for following condition "'2010-01-15' between e.enr_startDate and e.enr_endDate". how can we parametrize the query.select distinct m.mem_id, CASE m.gndr_Code WHEN 1 then 'Male' WHEN 2 then 'Female' ELSE 'Unknown' END as GenderDescription, DATEDIFF(yy,m.mem_Birthday,@enrollmentDate)from dbo.tbMember m inner join dbo.vw_Enrollment e on m.mem_id=e.mem_id AND '2010-01-15' between e.enr_startDate and e.enr_endDate |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-10 : 16:21:04
|
| declare a parameter by name @Date and use likeAND @Date >= e.enr_startDate and @Date< e.enr_endDate +1------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
cajay
Starting Member
2 Posts |
Posted - 2012-08-10 : 16:41:18
|
| can i give 3 different dates in the query at once and get results for all of it.similar to the followingwhen date in('20120101','20120201','20120301') |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-08-10 : 16:44:40
|
| What you have provided us so far doesn't make much sense. It'll be more helpful to supply examples with data and expected output. Please review the following links for how to refine your question. http://www.sqlservercentral.com/articles/Best+Practices/61537/http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-10 : 16:58:33
|
quote: Originally posted by cajay can i give 3 different dates in the query at once and get results for all of it.similar to the followingwhen date in('20120101','20120201','20120301')
are you looking for exact matches or range?previous question was on a range so not sure what exactly you're after------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|