By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,766 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,766 IT Pros & Developers. It's quick & easy.

selecting a date range using query

P: 66
hi friends..

i am using sql server 2005 reporting services..
in database the table contains startdate row and enddate row...
i want the query which display all the contents between these dates... when i externaly pass the startdate and enddate

SELECT *

FROM tmpFilePendStatPost
Where seccd=@seccd
GROUP BY
HAVING (fromdate = CONVERT(smalldatetime, @stdt, 103) AND todate=CONVERT(smalldatetime, @enddt, 103))

but the above query will give only that date contents.... it doesnot display the contents which is present b/w these dates...
how to do this plz help me...
Sep 9 '08 #1
Share this Question
Share on Google+
4 Replies


ck9663
Expert 2.5K+
P: 2,878
Use WHERE instead of HAVING

WHERE fromdate = CONVERT(smalldatetime, @stdt, 103) AND todate=CONVERT(smalldatetime, @enddt, 103)
GROUP BY.....

-- CK
Sep 9 '08 #2

P: 66
Use WHERE instead of HAVING

WHERE fromdate = CONVERT(smalldatetime, @stdt, 103) AND todate=CONVERT(smalldatetime, @enddt, 103)
GROUP BY.....

-- CK

but it ll display only that particular fromdate and todate reports, but i want the reports from that start date to enddate, i.e it should display the reports b/w these dates including the start and end date
Sep 10 '08 #3

ck9663
Expert 2.5K+
P: 2,878
use >= (greater than or equal)

Expand|Select|Wrap|Line Numbers
  1. WHERE fromdate >= CONVERT(smalldatetime, @stdt, 103) AND todate <= CONVERT(smalldatetime, @enddt, 103)
  2. GROUP BY.....
-- CK
Sep 10 '08 #4

P: 66
use >= (greater than or equal)

Expand|Select|Wrap|Line Numbers
  1. WHERE fromdate >= CONVERT(smalldatetime, @stdt, 103) AND todate <= CONVERT(smalldatetime, @enddt, 103)
  2. GROUP BY.....
-- CK

Thank you very much for u r reply.. its working
Sep 11 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.