467,149 Members | 1,206 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,149 developers. It's quick & easy.

selecting a date range using query

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
  • viewed: 2525
Share:
4 Replies
ck9663
Expert 2GB
Use WHERE instead of HAVING

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

-- CK
Sep 9 '08 #2
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 2GB
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
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.

Similar topics

1 post views Thread by Sunny K | last post: by
2 posts views Thread by Catherine | last post: by
12 posts views Thread by Steve Elliott | last post: by
3 posts views Thread by manning_news@hotmail.com | last post: by
2 posts views Thread by Julie Wardlow | last post: by
5 posts views Thread by Miquel van Smoorenburg | last post: by
67 posts views Thread by PC Datasheet | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.