locked
Changing Dates in a Stored Procedure RRS feed

  • Question

  • Hi I am looking for data dating back from 8/2006 through 12/2007. The Stored Procedures that I am using only go back to December of 2007. How can I change the dates so it gives me info from the desired time gap?

    This is the query I've been working on:


    DECLARE
    @start_time DATETIME,
    @end_time DATETIME,
    @month INT,
    @year INT


    SELECT
     @star_date = DATEADD(mm, -11, MIN(calendar_date)), @end_date = DATEADD(ss, -1, DATEADD(dd, 1, MAX(calendar_date)))

    FROM
    dim_date

    WHERE
    calendar_month = 8
    AND calendar_year = 2006

    SELECT
    calendar_month,
    calendar_year,
    calendar_month_name,
    COUNT(ffu.file_key) AS uploads

    FROM
    fact_file_uploads as ffu
    JOIN dim_date as dd
    ON ffu.upload_date_key = dd.date_key
    AND calendar_date BETWEEN @start_date  AND @end_date

    WHERE
    ffu.file_key != 0

    GROUP BY
    calendar_month,
    calendar_year,
    calendar_month_name

    ORDER BY
    calendar_month,
    calendar_year



    Thanks, appreciate the help...
    Wednesday, April 22, 2009 6:03 PM

Answers

  • Joe

    Note that this forum is dedicated to training/certification questiobns.  Your question would be better posed to a forum dedicated to SQL.
    • Marked as answer by joe87 Wednesday, April 22, 2009 6:59 PM
    Wednesday, April 22, 2009 6:22 PM
    Answerer

All replies

  • Joe

    Note that this forum is dedicated to training/certification questiobns.  Your question would be better posed to a forum dedicated to SQL.
    • Marked as answer by joe87 Wednesday, April 22, 2009 6:59 PM
    Wednesday, April 22, 2009 6:22 PM
    Answerer
  • Thank you


    ___________________________________________________________________________________________________________________________
    goldkurs in euro
    Wednesday, December 23, 2009 9:34 AM
  • Your "BETWEEN @start_date  AND @end_date" needs to be in your where clause.

    Jim Guy
    MCP, MCITP EA, CCNA, CEH

    Systems Administrator
    Kirkland, Washington
    Saturday, February 13, 2010 4:01 AM