DATEPART(quarter, DISCONTINUEDDATE) AS Quarter

  • *** Select items

    SELECT DISCONTINUEDDATE,Q1,Q2,Q3,Q4,

    *** CREATE A FIELD CALLED SUNSET BASED ON DISCONTINUEDDATE 6 MONTHS PRIOR

    DATEADD(m, - 6, DISCONTINUEDDATE) AS SUNSET,

    *** DIVIDE DISCONTINUEDDATE INTO QUARTERS

    DATEPART(quarter, DISCONTINUEDDATE) AS Quarter

    ** TABLE NAME

    FROM  EOL

     

    *** GET TODAYS DATE

    WHERE (DISCONTINUEDDATE > DATEADD(M, - 0, GETDATE()))

    *** ORDER BY

    ORDER BY DISCONTINUEDDATE

     

    Trying to figure out how to create the quarter fields based on DISCONTINUEDDATE so I can remove my static fields Q1-Q4.

    End Goal is to show 2 years worth of quarters with quarter and year.

     

    Any thoughts?

  • I'm a little confused on what your trying to do here.

     

    *** Select items

    SELECT DISCONTINUEDDATE,Q1,Q2,Q3,Q4,

    Is this how your final query needs to look?

    *** CREATE A FIELD CALLED SUNSET BASED ON DISCONTINUEDDATE 6 MONTHS PRIOR

    DATEADD(m, - 6, DISCONTINUEDDATE) AS SUNSET,

    Ths seems fine. But what does it have to do with your datepart(quarter) question?

    *** DIVIDE DISCONTINUEDDATE INTO QUARTERS

    DATEPART(quarter, DISCONTINUEDDATE) AS Quarter

    How do you divide a date into may quarters? what do you mean here. this statement will tell you what quarter that date is in.

    ** TABLE NAME

    FROM  EOL

     

    *** GET TODAYS DATE

    WHERE (DISCONTINUEDDATE > DATEADD(M, - 0, GETDATE()))

    This is working but I'm not sure the way you want

    this has the same effect -- DISCONTINUEDDATE > GETDATE()

    *** ORDER BY

    ORDER BY DISCONTINUEDDATE

    Can you post more information?

    How about your table definitions, some sample data, and how you want the query to look when its done.

    Thanks

    http://www.aspfaq.com/etiquette.asp?id=5006

     

  • I need to take one date and break it down into quarter with years so I can do a two year look ahead. 8 quarter vs the 4 I am doing now.

    thanks

     

    Mike

  • Well Like I said please present us with a sample table, some sample data, what your trying to do, and what you want as a result. and Someone can help you.

    A date is only in 1 single quarter, and in 1 single year.

     

  • There is only One row

    Discontinueddate

     

    with dates from 01/01/1983 - 01/01/2099

    From this I can get Which quarter 1-4 there are in

    and create and populate a quarter field

    I am trying to create and populate fields Q1 - Q4 instead of the One field Quarter.

    *DATEPART(quarter, DISCONTINUEDDATE) AS Quarter

     

     

    thanks

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply