selecting a date range using query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rekhasc
    New Member
    • Oct 2007
    • 66

    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 tmpFilePendStat Post
    Where seccd=@seccd
    GROUP BY
    HAVING (fromdate = CONVERT(smallda tetime, @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...
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Use WHERE instead of HAVING

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

    -- CK

    Comment

    • rekhasc
      New Member
      • Oct 2007
      • 66

      #3
      Originally posted by ck9663
      Use WHERE instead of HAVING

      WHERE fromdate = CONVERT(smallda tetime, @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

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        use >= (greater than or equal)

        Code:
        WHERE fromdate >= CONVERT(smalldatetime, @stdt, 103) AND todate <= CONVERT(smalldatetime, @enddt, 103)
        GROUP BY.....
        -- CK

        Comment

        • rekhasc
          New Member
          • Oct 2007
          • 66

          #5
          Originally posted by ck9663
          use >= (greater than or equal)

          Code:
          WHERE fromdate >= CONVERT(smalldatetime, @stdt, 103) AND todate <= CONVERT(smalldatetime, @enddt, 103)
          GROUP BY.....
          -- CK

          Thank you very much for u r reply.. its working

          Comment

          Working...