Quarter date...

Hello
I need to write a program to do the following:
User enters calendar quarter range on variable screen
if the "To" calquarter falls in the current quarter, data as of today-7days needs to be picked up
The issue is, how do I determine which quarter today falls in.. because the fiscal quarter we use is not the same as the calendar quarter. If March is 1st quarter in the regular calendar, for us it is the second quarter. Is there a way for me to maintain the quarter start and end dates for the program to read?
Thanks
Kashka.

SQL> with t as (
  2             select 'Q1 2007' d from dual union all
  3             select 'Q2 2007' d from dual union all
  4             select 'Q3 2007' d from dual union all
  5             select 'Q4 2007' d from dual union all
  6             select 'Q1 2008' d from dual union all
  7             select 'Q2 2008' d from dual union all
  8             select 'Q3 2008' d from dual union all
  9             select 'Q4 2008' d from dual
10            )
11  select  *
12    from  t
13    where to_date(d,'"Q"MM YYYY') > to_date('Q3 2007','"Q"MM YYYY')
14  /
D
Q4 2007
Q1 2008
Q2 2008
Q3 2008
Q4 2008
SQL> SY.

Similar Messages

  • Help needed in getting the previous Quarter Data

    Hello folks,
    I have this procedure where i have to modify the current procedure in the following manner:
    I need to get rid of the variables p_start and p_end so that i cannot see them in the crystal report and include the Frequency in the procedure to get the Data based on the Dates.
    and Main requirement is" If the Frequency is Quarterly " it should get the previous quarter Data, if "Frequency is monthly" it should return the previous month data.Can anyone please let me know where shud i make changes. Am including the procedure for refernce. Any help is appreciated
    Thanks a millioin,
    CREATE OR REPLACE PROCEDURE hcsc_recovery_report_h(report_record in out cr_return_types.gen_cursor,
    p_start       string,
    p_end         string)
    IS
    v_startdate date;
    v_enddate date;
    BEGIN
    v_startdate := to_date(p_start, 'YYYY/MM');
    v_enddate := last_day(to_date(p_end, 'YYYY/MM'));
    open report_record for
    select --distinct r.recovery_id
    r.event_id,
    r.event_case_id,
    c.client_id,
    c.client_code,
    c.client_name,
    b.branch_group_code,
    b.branch_group_description,
    g.employer_group_code,
    g.employer_group_name,
    e.client_policy_identifier,
    e.date_of_incident,
    e.event_type_code,
    sum(nvl(r.amount, 0)) as amt_received,
    nvl(sum(case
    when r.amount >= 0 then
    rd.fees
    else
    rd.fees * (-1)
    end),
    0) as fees,
    ec.close_date, *001* commented
    (case
    when ec.close_date <= to_date(to_char(v_enddate, 'MMDDRRRR') || '235959',
    'MMDDRRRR HH24MISS') then
    ec.close_date
    else
    null
    end) as close_date, --*001*  added
    get_case_value(ec.event_id, ec.event_case_id, v_enddate) as case_value,
    nvl(etl.fee_percent_flag, 'N') workmans_comp,
    max(to_char(r.recovery_date, 'FMMonthYYYY')) Year_Month,
    max(to_char(r.recovery_date, 'YYYYMM')) Y_M,
    max(to_date(to_char(r.recovery_date, 'MMYYYY'), 'MM/YYYY')) date_MY
    from recovery r,
    recovery_detail rd,
    event e,
    client c,
    branch_group b,
    employer_group g,
    event_case ec,
    event_type_lookup etl
    where r.event_id = e.event_id
    and r.event_case_id = ec.event_case_id
    and ec.event_id = e.event_id
    and rd.recovery_id(+) = r.recovery_id
    and r.recovery_date between v_startdate and
    to_date(to_char(v_enddate, 'MMDDRRRR') || '235959',
    'MMDDRRRR HH24MISS')
    and e.client_id = c.client_id
    and g.client_id = c.client_id
    and b.client_id = c.client_id
    and g.employer_group_id(+) = e.employer_group_id
    and b.branch_group_id(+) = g.branch_group_id
    and e.event_type_code = etl.event_type_code -- SST 130852 04/14/09
    group by r.event_id,
    r.event_case_id,
    c.client_id,
    c.client_code,
    c.client_name,
    b.branch_group_code,
    b.branch_group_description,
    g.employer_group_code,
    g.employer_group_name,
    e.client_policy_identifier,
    e.date_of_incident,
    e.event_type_code,
    ec.close_date,
    get_case_value(ec.event_id, ec.event_case_id, v_enddate),
    nvl(etl.fee_percent_flag, 'N')
    having sum(nvl(r.amount, 0)) <> 0
    order by c.client_code,
    b.branch_group_code,
    g.employer_group_code,
    r.event_case_id;
    Edited by: user11961230 on Oct 20, 2009 9:02 AM

    user11961230 wrote:
    1. I want to get rid of the p_start and p_end. So how do i declare the v_startdate and v_enddate in the following part?
    v_startdate := to_date(p_start, 'YYYY/MM');
    v_enddate := last_day(to_date(p_end, 'YYYY/MM'));I'm not sure what you mean by "declare".
    In PL/SQL, "declare" means state (at the beginning of a block) that there will be a certain variable with a certain name (such as v_startdate) and datatype (such as DATE). You're already declaring the variables v_startdate and v_enddate correctly, right before the BEGIN statement.
    Declaring a variable is not the same as initializing it, that is, giving it a value for the first time. Your next question seems to be about initializing..
    2. where exactly shud i include the logic that u have mentioned. sorry a dumb questionIn place of the two assignment statments that reference p_start and p_end.
    3. This time am gonna use frequency instead of report_type so that i will get rid of the p_start and p_end from the procedure.Do you mean you want to pass an argument (called frequency) that tells if you want a quarterly or a mionthly report, just like the variable report_type in my example?
    If so, replace report_type in my example with frequency.
    I think you want something like this:
    CREATE OR REPLACE PROCEDURE hcsc_recovery_report_h
    (      report_record         in out     cr_return_types.gen_cursor
    ,      frequency         IN           VARCHAR2
    IS
         -- Declare local variables:
         v_startdate     date;
         v_enddate      date;
    BEGIN
         -- Initialize v_startdate and v_enddate, depending on frequency
         IF  frequency = 'QUARTERLY'
         THEN
              v_startdate := TRUNC ( ADD_MONTHS (SYSDATE, -3)
                                           , 'Q'
              v_enddate := TRUNC (SYSDATE, 'Q');
         ELSIF  frequency = 'MONTHLY'
         THEN
              v_startdate := TRUNC ( ADD_MONTHS (SYSDATE, -1)
                             , 'MM'
              v_enddate := TRUNC (SYSDATE, 'MM');
         END IF;
         --   Subtract one second from v_enddate
              v_enddate := v_enddate - ( 1
                                            / (24 * 60 * 60)
         open report_record for
         select --distinct r.recovery_id
                r.event_id,
         and     r.recovery_date  BETWEEN  v_startdate     
                         AND       v_enddate
         ...When you post formatted text on this site (and code should always be formatted), type these 6 characters:
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Edited by: Frank Kulash on Oct 20, 2009 2:37 PM
    Changed query to use BETWEEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need to display the Current Quarter Data

    Hi Gurus,
    We have a requirement in the report as follows:
    I have a Key Figure - 0Balance. In this it should display the current quarter data.
    We have 5 plants and this report is specific to a plant X which runs 3 month behind.
    So in the variables screen, if I enter 006.2007, it should display the data of 003.2007. Please guide me through the steps...Thanks in advance.

    Hi,
    For getting current quarter data there is std variable available 0CMCQUAR , restrict KF wiht the variable and system should show you current quarter balance.
    For getting balance for previous quarter , copy the kf just created and right click on it , click on the variable right hand side -> specify offset -> put -1. and it should give last quarter data.
    Hope that helps.
    Regards
    Mr Kapadia

  • Quarter Dates

    How do I get previous and next quarter dates in coldfusion?
    Using the below function I will get current quarter.
    <cfoutput>#Quarter(Now())#</cfoutput>. --->
    Output ---> Q1
    Q#Quarter(Now())#-#DateFormat(Now(), "yyyy")# --> Output
    ----> Q1-2007
    I want the previous and next quarter dates in below format.
    (Considering the date as today's date ie. 21st Feb 2007)
    Q4-2006 from (October 1st to December 31st).
    Q2-2007 from (April 1st to June 30th).
    Can anyone help me.
    Thanks & Regards,
    Satheesh.

    Thanks guys for your reply.
    I have done it through sql query:
    The below query will give me out of previous quarter with
    year.
    If Getdate() - 2007-02-21 15:29:22.850
    I require previous quater. Hence I used the below logic in
    SQL Server.
    SELECT
    CASE WHEN MONTH(GETDATE()) IN ( 1, 2, 3) THEN 'Quarter 4, ' +
    CAST(YEAR(GETDATE())-1 AS VARCHAR(4))
    WHEN MONTH(GETDATE()) IN ( 4, 5, 6) THEN 'Quarter 1, ' +
    CAST(YEAR(GETDATE())-1 AS VARCHAR(4))
    WHEN MONTH(GETDATE()) IN ( 7, 8, 9) THEN 'Quarter 2, ' +
    CAST(YEAR(GETDATE())-1 AS VARCHAR(4))
    WHEN MONTH(GETDATE()) IN (10, 11, 12) THEN 'Quarter 3, ' +
    CAST(YEAR(GETDATE())-1 AS VARCHAR(4))
    END as PreQuarter

  • FR : How to change from monthly to YTD or quarter data in the same report

    Hi,
    We have several basic reports with 12 month in columns with monthly figures. We would like to try to improve these reports with 2 options (and not creating new reports):
    - For each month, we would like to choose between monthly & year to date figures. (we do not have a view dimension with YTD member)
    - In our period dimension we also have quarter members. How to choose between displaying month or quarter with the prompts ? (ie without having to select each month one by one)
    Does it is possible to do this with FR without adding a new dimension for monthly or YTD data?
    thanks!
    Tipiak

    Hi Tipiak,
    In order to show YTD Actual figure for the selected month, I was doing something like that
    - Add a hidden col from Jan to Run Time period selected.
    - Add a visible formula col and add the formula showing the total of the hidden col.
    Your requirement seems more complex but you might meet some part as an initial step maybe...
    Regards,
    Ahmet

  • Cross tab on quarter (date) parameter

    Post Author: tomahawk
    CA Forum: Charts and Graphs
    I need to design a cross tab report where the column is a certain date field (say date1). However, the report is a quarterly report, so the columns should be for each quarter (date1 falling in a particular quarter). The user wants to select the quarter from a drop down parameter box at runtime. How do i set the condition/formula for the cross tab to display details for the quarter that the user selected?
    Please help urgently.
    Thanks
    Tom

    Post Author: sleahcim
    CA Forum: Charts and Graphs
    Hi Tom,
    While there may be some method to do it by playing around with the formatting, you're likely to get it done quicker by creating a formula for your quarters, and swapping that field into your crosstab.  Here's a sample report that shows you how to create a quarter formula.
    -Michael

  • Displaying current and prior quarter data in FR

    Hi,
    I have two grids in report.Grid 1 and Grid 2.
    I have to display data for current quarter and current year in Grid1
    and Grid 2 should display data for prior quarter and year should change accordingly.
    Ex Grid1 : Q4 2008 Then Grid2: Q3 2008, this works by using relative period.
    But problem is when Grid1: Q1 2008, Grid2 should be: Q4 2007.
    How would this be possible?Can we use any formula or condition?
    Any idea would be appreciated.
    Thanks

    Of course it works, I tested on my environment, independently of what I have as accounts or anything else. If you want Grid2 to show the prior Quarter swap the values like this:
    Grid1 Column A: Current Point of View for Period
    Current Point of View for Year
    Grid2 Column A: Period Current Point of View for Period offset by -1
    Current Point of View for Year
    You dont need to worry about the Year, for it knows to go back based on the other parameters.
    If you select in your POV__________________________Year: 2008________________________Period: Q1
    You will get the following results:
    Grid2: Q4 2007
    Grid1: Q1 2008

  • Sql query for quarter data..Please help

    Dear Experts,
    Please help with this query...
    i have data like below:
    Year
    Quarter
    MRR
    MRR%
    2012
    Q1
    10
    Q2
    30
    Q3
    50
    Q4
    60
    2013
    Q1
    20
    Q2
    30
    Now i need to caluclate MRR % column values as below
    for 2012 Q2 MRR % = (Q2MRR-Q1MRR)/Q1*100 that is (30-10)/10*100
    for 2012 Q3 MRR % = (Q4MRR-Q3MRR)/Q2*100
    for 2012 Q4 MRR %=  (Q1MRR-Q4MRR)/Q1*100  here q1 of 2013 and q4 of 2012...
    like this it wll go on..
    Please help with me query compute values in MRR % column.
    Best regards
    asp

    Maybe NOT TESTED! No Database at hand
    select year,quarter,mrr,
           ratio_to_report(q_mrr) over (partition by year order by quarter) pct_mrr
      from (select year,quarter,mrr,
                   mrr - lag(mrr,1,0) over (partition by year order by quarter) q_mrr
              from t
    Regards
    Etbin

  • Last Quarter Dates.

    Hi,
    I was told to come up with the starting and ending date for the last quarter and I came up with this code. Could this have been written in any other way?
    CREATE OR REPLACE PROCEDURE last_quarter_dates(p_start_date OUT DATE,
                                                   p_end_date   OUT DATE) IS
    BEGIN
      SELECT CASE to_char(SYSDATE,
                      'Q')
               WHEN '1' THEN
                to_date('Oct-1-' ||
                        to_char(to_number(to_char(SYSDATE,
                                                  'YYYY')) - 1),
                        'Mon-DD-YYYY')
               WHEN '2' THEN
                to_date('Jan-1-' || to_char(SYSDATE,
                                            'YYYY'),
                        'Mon-DD-YYYY')
               WHEN '3' THEN
                to_date('Apr-1-' || to_char(SYSDATE,
                                            'YYYY'),
                        'Mon-DD-YYYY')
               WHEN '4' THEN
                to_date('Jul-1-' || to_char(SYSDATE,
                                            'YYYY'),
                        'Mon-DD-YYYY')
             END start_date,
             CASE to_char(SYSDATE,
                      'Q')
               WHEN '1' THEN
                to_date('Dec-31-' ||
                        to_char(to_number(to_char(SYSDATE,
                                                  'YYYY')) - 1),
                        'Mon-DD-YYYY')
               WHEN '2' THEN
                to_date('Mar-31-' || to_char(SYSDATE,
                                             'YYYY'),
                        'Mon-DD-YYYY')
               WHEN '3' THEN
                to_date('Jun-30-' || to_char(SYSDATE,
                                             'YYYY'),
                        'Mon-DD-YYYY')
               WHEN '4' THEN
                to_date('Sep-30-' || to_char(SYSDATE,
                                             'YYYY'),
                        'Mon-DD-YYYY')
             END end_date
        INTO p_start_date, p_end_date
        FROM dual;
    END last_quarter_dates;

    Hi,
    The TRUNC function makes this much easier:
    SELECT     TRUNC (ADD_MONTHS (SYSDATE, -3), 'Q')
    ,     TRUNC (SYSDATE, 'Q') - 1
    INTO     p_start_date
    ,     p_end_date
    FROM     dual;TRUNC (dt, 'Q') is the beginning of the quarter that contains dt.
    ADD_MONTHS (dt, -3) is the date 3 months before dt, which will always be in the quarter before dt itself.
    Edited by: Frank Kulash on Mar 30, 2009 12:44 PM
    As Boneist said, this is so simple you might not want a procedure for it.
    Whenever you write a procedure, make it general enough to handle related problems that may arise in the future.
    For example, right now you only need to find p_start_date and p_end_date relaticve to today's date.
    Don't you think the same problem may come up, relative to some arbitrary given date?
    You can write the proceudre so that it handles both cases. Make today the default date, but allow the caller to supply any other given date if needed.
    CREATE OR REPLACE PROCEDURE     last_quarter_dates
    (      p_start_date     OUT     DATE     -- Beginning of quarter
    ,      p_end_date     OUT     DATE     -- End of quarter (e.g., 31-Dec-2008 00:00:00 (not 23:59:59)
    ,      p_base_date     IN     DATE     DEFAULT       SYSDATE
    IS
    --     last_quarter_dates sets p_start_date and p_end_date to midnight of
    --          the first and last days in the quarter BEFORE p_base date
    --          (not the quarter containing p_base_date).
    --     For example, if this is run anytime in the first quarter of 2009,
    --             and p_base_date is not given, then
    --          p_start_date will be sert to  01-Oct-2008 00:00:00, and
    --          p_end_date                        31-Dec-2008 00:00:00
    BEGIN
         SELECT     TRUNC ( ADD_MONTHS (p_base_date, -3), 'Q')
         ,     TRUNC (              p_base_date,      'Q') - 1
         INTO     p_start_date
         ,     p_end_date
         FROM     dual;
    END     last_quarter_dates;

  • Quarter-- Date Mask issue

    I have a varchar column which contains values like
    Q1 2007
    Q2 2007
    Q3 2007
    Q4 2007
    Q1 2008
    Q2 2008
    Q3 2008
    Q4 2008
    I need to select the values greater than 'Q3 2007'. Can you please help
    Thanks in Advance

    SQL> with t as (
      2             select 'Q1 2007' d from dual union all
      3             select 'Q2 2007' d from dual union all
      4             select 'Q3 2007' d from dual union all
      5             select 'Q4 2007' d from dual union all
      6             select 'Q1 2008' d from dual union all
      7             select 'Q2 2008' d from dual union all
      8             select 'Q3 2008' d from dual union all
      9             select 'Q4 2008' d from dual
    10            )
    11  select  *
    12    from  t
    13    where to_date(d,'"Q"MM YYYY') > to_date('Q3 2007','"Q"MM YYYY')
    14  /
    D
    Q4 2007
    Q1 2008
    Q2 2008
    Q3 2008
    Q4 2008
    SQL> SY.

  • Query to find out last quarter data

    Hi All,
    I need a SQL query to find out. I have an amount field like below
    Period | Amt | Amt2
    ====================
    Jul | 0 | 0+20+30
    Aug | 20 | 0
    Sep | 30 | 0
    Oct | 0 | 0+50
    Nov | 50 |
    My need is Amt2 which needs to calculating in Qtr wise. Can any one post me a query for this.
    Thanks,
    Kamal

    Hi Valli,
    Thanks, so we need to create a function and then call that from report. I have doubt in this, for example if the user enter 'SEP-12' then it will find which QTR from the case statement. But if the user have account number which is available in all the months from 2010 - 2012.
    So now user will give two inputs like period_name='SEP-12' and Account Number=101010 then it should give output like sum(Q3) in the year of 2012. Here how it will calculate year wise? or do we need to specify any condition here?
    Please advice,
    Thanks,
    Kamal

  • Quarter to date (QTD)

    Hi Alla,
    I have a report to display QTD Quantity. when ever i ran the report QTD data is calculating this year (2001) quarter and last ( 2010) year data ( we have only 2 years data ).
    I mean if i run the report today it should display from Apr 2011 data only but it is adding last year Apr 2010 , may and june 2010 data also ( because Apr, may and june also Quarter 2).
    i have one column as Quarter ( Quarter-of-year ( date)) and using todate function .
    how can i get only this year quarter data in my report.
    I rally appreciated for you help.
    Thanks

    Thanks David For your response.
    I am using Union report . i did try with filter for current year but it is not working . i am not sure is current year filter is work with UNION or not.
    FYI: if i create simple report current year filter is working fine.
    Thanks

  • Retrieve quarter-year from give data parameter

    Hi All,
    We are using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0.
    I want to write a query to display the records of a querter based on the input date parameter value.
    i.e. If user input 06-DEC-2010 then system should retrieve only 4th Quarter data of the Year 2010 from 01-OCT-2010 to 31-DEC-2010
    If user input 02-FEB-2010 then system should retrieve only 1st Quarter data of the Year 2010 from 01-JAN-2010 to 31-MAR-2010 (in this case only till 02-FEB-2010)
    If user input 31-DEC-2009 then system should retrieve only 4th Quarter data of the Year 2009 from 01-OCT-2010 to 31-DEC-2010
    The data column exists in the table.
    Regards,
    Hassan

    Something like
    my_date_column between trunc(p_input_date,'Q')
            and add_months(trunc(p_input_date,'Q'),3) - 1http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions220.htm#i79761
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions011.htm#i76717

  • Getting quartely sales data

    Hi I've the following data . and i confused to get the quartely data from the below table
    Could you please help out with the skelton query to get the quartely data .
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (13413, 'Air Regulators', 2450, 144, 2,
        5.09, TO_DATE('04/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (13414, 'Air Regulators', 1165, 144, 3,
        10.52, TO_DATE('04/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (13630, 'Air Regulators', 3260, 144, 4,
        20.53, TO_DATE('04/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (13890, 'Air Regulators', 270, 145, 1,
        10.31, TO_DATE('06/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (19286, 'Small Equipments', 688, 145, 2,
        3.99, TO_DATE('06/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (13413, 'Air Regulators', 2450, 145, 3,
        20.5, TO_DATE('06/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (23314, 'Small Equipments', 1390, 145, 4,
        10.5, TO_DATE('06/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (23541, 'Small Equipments', 1105, 146, 2,
        10.5, TO_DATE('06/09/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ORDER_ITEMS
       (ITEM_ID, ITEM_DESC, PRICE, ORDER_ID, QUANTITY, DISCOUNT, DATE_ENTERED)
    Values
       (23743, 'Small Equipments', 3235, 146, 1,
        10.5, TO_DATE('06/09/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;Thank you for your suggestions
    Edited by: Smile on Jan 7, 2013 10:55 AM

    Hi,
    If you're using the standard quarters (that is, quarters begin on January 1, April 1, July 1 and October 1), then you can use the TRUNC function, like this:
    SELECT       TO_CHAR ( TRUNC (date_entered, 'Q')
                  , 'YYYY "Q"Q'
                )               AS quarter
    ,       COUNT (DISTINCT item_id)     AS item_cnt
    ,       SUM (price * quantity)     AS total_sales
    FROM       order_items
    GROUP BY  TRUNC (date_entered, 'Q')
    ORDER BY  TRUNC (date_entered, 'Q')
    ;Even if your quarters are not the standard ones (e.g., if new quarters begin on the 15th of February, May, August and November), you still might want to use TRUNC.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data. The INSERT statements you posted are good, but it looks like all the data is from the same quarter. Perhaps some data from different quarters, even different years, would be a better test.
    Explain, using specific examples, how you get the results you post from the given data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • SSRS Date parameter - current month from SSAS cube

    I have a SSAS cube with a date dimension called Posting Period and now I would like to have my report parameter using this date dimension to show the current month.
    So far I have worked out the following expression which are working(Fiscal year calendar going from May to May) for the year component - but I can't figure out how to get it to work on Quarter date part (and the month) so as you can see
    the Quarter and month is hardcoded in the below expression:
    ="[PostingPeriod].[Posting Period].[Year].&[" + CStr(Year(Today())-1) + "].&[Q4].&[10]”
    Any help would be appriciated.
    Tx

    Hi HCMJ,
    In your scenario, you use the expression
    ="[PostingPeriod].[Posting Period].[Year].&[" + CStr(Year(Today())-1) + "].&[Q4].&[10]”
    to set the default value of the parameter and then use it in the MDX query, right?
    If in this case, you can use the expression below
    ="[PostingPeriod].[Posting Period].[Year].&[2013].&[Q" & DatePart(DateInterval.Quarter,today()) & "].&[10]”
    to set the value on Quarter date part.
    And it returns:
    If I have anything misunderstood, please point it out and elaborate the meaning of "but I can't figure out how to get it to work on Quarter date part (and the month) so as you can see the Quarter and month is hardcoded
    ", so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

Maybe you are looking for