Exact date range comparison

I have payment table like this,
Date | Store | payment
01/01/2012 | A | $300 
01/01/2012 | B | $400 
01/01/2012 | C | $500 
01/02/2012 | A | $500
01/22/2015 | C | $300
I want to make a report like this,
                              A                                          
                B                           ........     Totals
        Current year | Last Year | Difference         Current year | Last Year | Difference .....     Totals
Jan
Feb
March
Dec
However for comparing last year & current year, I only want to take into account the number of days in the current month. For instance, if current year-month sales are only up-to-date until 22 then for previous year, i want to show sales for Jan only
until 22.
I know I can hardcode this for previous year sales  by specifying harcoded dates, but anytime I try using something like calculate(sum(payment), formula to calculate last date in current year and use dateadd() formula move this back by one year) always
results in error like "cannot use formula in calculate filter"
is there any solution to this? 

PaymentYTD:=CALCULATE(SUM([Amount]),DATESYTD(Dates[Date],"12/31"))
PaymentPriorYear:=CALCULATE([PaymentYTD],
SAMEPERIODLASTYEAR(Dates[Date]))
The dates in Dates tables are contiguous, however there are missing dates in payment table (as the store for closed for some of the holidays). Below
is sample data, 
PAYMENT_DATE
AMOUNT
STORENO
PAY_DATEKEY
01/02/2014 9:51
$359.00
1
01/02/2014
01/02/2014 10:08
$283.00
1
01/02/2014
01/02/2014 10:09
$497.00
1
01/02/2014
01/02/2014 10:23
$494.00
1
01/02/2014
01/02/2014 10:34
$27.00
1
01/02/2014
01/02/2014 10:34
$63.00
1
01/02/2014
01/02/2014 10:56
$453.00
3
01/02/2014
01/02/2014 10:56
$175.00
3
01/02/2014
01/02/2014 10:59
$197.00
1
01/02/2014
01/02/2014 11:00
$145.00
1
01/02/2014
01/02/2014 11:01
$373.00
3
01/02/2014
01/02/2014 11:06
$475.00
1
01/02/2014
01/02/2014 11:10
$413.00
2
01/02/2014
01/02/2014 11:11
$431.00
2
01/02/2014
01/02/2014 11:13
$131.00
2
01/02/2014
01/02/2014 11:16
$34.00
2
01/02/2014
01/02/2014 11:16
$59.00
2
01/02/2014
01/02/2014 11:17
$203.00
1
01/02/2014
01/02/2014 11:19
$80.00
1
01/02/2014
01/02/2014 11:27
$418.00
1
01/02/2014
01/02/2014 11:27
$198.00
1
01/02/2014
01/02/2014 11:28
$354.00
2
01/02/2014
01/02/2014 11:29
$19.00
2
01/02/2014
01/02/2014 11:33
$425.00
3
01/02/2014
01/02/2014 11:34
$296.00
2
01/02/2014
01/02/2014 11:34
$302.00
1
01/02/2014
01/02/2014 11:35
$244.00
3
01/02/2014
01/02/2014 11:35
$13.00
3
01/02/2014
01/02/2014 11:39
$419.00
2
01/02/2014
01/02/2014 11:43
$144.00
2
01/02/2014
01/02/2014 11:43
$206.00
2
01/02/2014
01/02/2014 11:47
$194.00
3
01/02/2014
01/02/2014 11:48
$479.00
3
01/02/2014
01/02/2014 11:53
$20.00
1
01/02/2014
01/02/2014 12:06
$419.00
1
01/02/2014
01/02/2014 12:15
$129.00
1
01/02/2014

Similar Messages

  • Date range Comparison to Period

    Hi Guys
    I have a selection screen date range. I want to select the agreements from a table whose Period is within the selection screen date range . what is the most appropriate way of compairing a period fied with date range??
    Thanks in Advance
    Harkamal

    Hi , u can try FM like this
    MM_ARRANG_SPMON_RANGE
    regards
    Prabhu

  • Date range parameters are off by one day

    I have a Start Date and End Date parameter in my SSRS report.  The results are off by 1 day.  For example if I enter 4/2/2015 and 4/20/2015 it will return a few results from 4/1/2015 to 4/19/2015.  I think maybe it's a problem with my date
    conversion in T-SQL, but thought someone more experienced than me would have seen this before.
    Thanks

    Yes 
    The safest way to write a date range comparison would be as below
    WHERE DateField >= @StartDate
    AND DateField < DATEADD(dd,1,@EndDate)
    If you want results with @EndDate inclusive
    see more details here
    http://visakhm.blogspot.ae/2012/12/different-ways-to-implement-date-range.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • No Data in Reports Details in Custom date range

    Hello, iTunes U Public Site Manager Admins.
    As the iTunes U Public Site Manager admin, I've been trying to access our institution's iTunes U Reports Details for a couple of days. (I send a monthly report of usage to our course/collection contributors.) When I custom the date range, under Details, there is zero entry; "No data available in table" message is shown.
    This feature had been working well since Apple iTunes U added this enhancement on August 13, 2013. The report Details showed the exact stats for Browse, Subscribe, Download, Stream, and Enclosure for each course/collection in the custom date range.
    Now under "Details", the data is shown only when the date range is Last 30 Days. It shows no data in custom date range when the Calendar is used to select a Start Date and End Date.
    Has anyone else noticed this problem?
    Thanks.
    Q. Wang

    Erik.
    I used your suggestion and it worked very well. This is how I did it.
    Export the range of data that includes Feb. 1-Feb. 28, 2014 as .tsv file.
    Open that file in Excel.
    Add a blank column next to the Date column. Use function =Month() to just extract the month into the new column. Fill down the whole column. Then copy and paste special (value) into the same column (I have over 26,000 rows of data in the file.) Converting to Value will allow for the next step of PivotTable.
    Create a PivotTable for the 26,000 rows of data. Use Month as the Report filter, iTunes_ID as the Row Labels, Select Browse, Subscribe, etc. as the Sum Values. (The result is a summary table with about 200 rows.)
    I then do a Vlookup to my premade Master file to add Category (course, collection, resources) and Instructor Name to each of the 200 rows.
    That will do it for my monthly report.
    Thanks for your tip again. I did not know the .tsv file would have DATE for each item.
    Sincerely,
    Q. Wang

  • Passing a date range to a Crystal Report using OpenDocument

    Hi,
    I am trying to call up a Crystal report in InfoView using a hyperlink with the OpenDocument function call.
    It is working fine with the following URL:
    http://<server name>:<port>/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=ARcnOcErTA1FidjRJ_sT0Yw&sType=rpt&sRefresh=Y&lsSCompany+Code=1300&lsMCost+Center=[12345],[67890]&lsSCost+Element=0000100123
    However, once I added the date range into the parameter string, like this:
    http://<server name>:<port>/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=ARcnOcErTA1FidjRJ_sT0Yw&sType=rpt&sRefresh=Y&lsSCompany+Code=1300&lsMCost+Center=[12345],[67890]&lsSCost+Element=0000100123&lsRFiscal+Year+Period=[Date(1,1,2011)..Date(1,9,2011)]
    It returns an error message, "An error has occurred: java.util.Date ", to my browser.
    I am wondering if I am missing any Java library or Java class path.
    Any thoughts are appreciated.
    Joyce
    Edited by: Joyce Chan on Aug 30, 2011 12:25 PM

    How do I check if the parameter passing in is in date type?
    the following is exactly what I've tried:
    &lsRFiscal+Year+Period=[Date(2010,10,10)..Date(2010,10,15)]
    Would the error message be logged in the server, maybe I can find more information for the error log?

  • How to limit data range in a Line chart with Time Refresh Control

    Hi All,
    I have a Line chart with Time Refresh Control and I would like to make some constraints to this navigation.
    For example, I would like to limit the user to navigate in a data range of 8 hours.
    Is this posible?
    Thanks in advance

    Hi Pedro,
    as far as I know, this is not possible using the time controls on an iChart. However, you may have some success by using your own time controls which call JavaScript methods exposed by the applet.
    For example, you could begin by hiding the time and calendar buttons on an iChart, and creating some buttons of your own. For instance, to set the start date of a query (and thus the start date of the iChart using the query), you can use the following:
    document.getElementById("appletID").getQueryObject().setStartDate(<date string>);
    Using code like the above (look into the xMII script assistant and documentation), you should be able to build time controls which satisfy your requirements. The exact format of <date string> in the sample above will depend on the date format defined in the query template this script calls.
    Hope this helps,
    Sascha

  • Multi Mailbox Search Date Range Results Inaccurate

    Hi All,
    I have an Exchange 2010 server with SP3 /RU3 installed. When I do a multi mailbox search using OWA /ECP and put in a start and end date from the Date Range dropdown box, my search results shows me more than just the intended date range of emails. For
    example; if I request just a particular month and year, my results will show a couple of years worth of emails not just the one month that I requested.
    If I do the same exact search using PowerShell command the results are accurate, they will show only the one month. We could use PowerShell commands but we'd would rather use the OWA /ECP console instead. To me it seems like a bug in the code. Has anyone
    else experience this issue or have a resolution?
    Thanks in advance.
    LJC321

    Possibly, this could be BUG.
    Haven't experience this kind of issue...
    Cheers,
    Gulab Prasad
    Technology Consultant
    My Blog:
    Exchange Ranger
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Assign Month within a date range (by most days in a given month)

    I have a begin and end date, sample data as such
    select to_date('01-13-12','mm-dd-yy') from_dt,
    to_date('02-23-12','mm-dd-yy') to_dt
    from dual
    union all
    select to_date('03-15-2012','mm-dd-yy') from_dt,
    to_date('04-16-2012','mm-dd-yy') to_dt
    from dual
    union all
    select to_date('05-13-2012','mm-dd-yy') from_dt,
    to_date('07-23-2012','mm-dd-yy') to_dt
    from dual
    How do I assign a month by the most days in a month within that date range? Sometimes the date range might have the exact same amount of days in a month (like 3/15/2012 has 16 days and 4/16/2012 has 16 days). In this case, I want the earlier month (march).
    So from the sample data:
    01/13/2012, 02/23/2012, February
    03/15/2012, 04/16/2012, March
    05/13/2012, 07/23/2012, June
    Thanks
    Edited by: user4422426 on Mar 1, 2012 5:15 PM

    Hi,
    Here's one way:
    WITH     cntr          AS
         SELECT     LEVEL - 1     AS n
         FROM     (
                   SELECT      1 + MAX (to_dt - from_dt)     AS max_day_cnt
                   FROM     table_x
         CONNECT BY     LEVEL     <= max_day_cnt
    ,     got_r_num     AS
         SELECT     x.from_dt, x.to_dt
         ,     TRUNC (x.from_dt + c.n, 'MONTH')     AS month
         ,     count (*)                    AS cnt
         ,     ROW_NUMBER () OVER ( PARTITION BY  from_dt, to_dt
                             ORDER BY        COUNT (*)     DESC
                             ,             TRUNC (x.from_dt + c.n, 'MONTH')
                           )     AS r_num
         FROM       cntr     c
         JOIN       table_x  x  ON  c.n  <= x.to_dt - x.from_dt
         GROUP BY  x.from_dt, x.to_dt
         ,       TRUNC (x.from_dt + c.n, 'MONTH')
    SELECT     from_dt, to_dt
    ,     TO_CHAR (month, 'Mon YYYY')     AS mon
    ,     cnt
    FROM     got_r_num
    WHERE     r_num     = 1
    ;Thanks for posting code to create the same data. Please test your code before you post it: you got the order of arguments to TO_DATE reversed.

  • How to get XLR to show BPs with no transaction data for a given date range

    Hi -
    I am building an XLR report that does a comparison of net sales data across two periods for a given sales employee's BPs.
    The report has the row expansion:
    FACT BPA(*) SLP(SlpName = "ASalesPersonNameHere") ARDT(Code = "ARCreditMemo", "Invoice") Group by BPA.CardName
    and column expansions:
    FIG(SO_TaxDate = @StartDate:@EndDate)
    and
    FIG(SO_TaxDate = @StartDate2:@EndDate2)
    where @StartDate, @EndDate, @StartDate2, @EndDate2 are parameters that define the two ranges of dates.
    The column formulas are, from left to right:
    =ixDimGet("BPA", "CardName")
    =ixGet("SO_DocTotal")      <-- filtered by column expansion for first date range
    =ixGet("SO_DocTotal")      <-- filtered by column expansion for second date range
    The report works fine except for one problem, I would like it to include BPs for which no transaction occurred in either date range as well.
    Any help is greatly appreciated!
    Thanks,
    Lang Riley

    Really appreciate your feedback!  Those are good suggestions. I should have mentioned that I had already tried both those suggestions.
    Removing FACT on BPA in this case ends up returning all the BPs and not respecting the SLP(SlpName = "aName") part of the query. 
    Using **, i.e., * or #NULL, makes no change in the resulting data in this case.  I had thought that ** would be the solution, but it didn't change the outcome.  I still have BPs for which when their sales employee is used as the filter and they have no transactions for either date range, and yet they still do not appear. 
    I should further mention that the IXL query, as it now stands, does return BPs for which one of the periods has no data, just not both, and I have verified that applicable BPs with no transaction data for both periods do exist in my data set.  It seems that perhaps the IXL query needs to be restructured?  Please keep the suggestions coming including how this query might be restructured if necessary.

  • Format Date Range in Select Statement e.b. 4/10/14 - 4/09/15

    So far thanks for all the help you've provided me on here. I'm a long time Access developer and have just worked with SQL very little throughout the years but now I'm working full-scale in it, so a learning process for me.
    I am familiar with the DateADD function in SQL DATEADD(mm, 1, GETDATE())  AS MyDate. The part that I'm struggling with is that I need to show a date range in a single field. I can not do it by having that function twice because of the character"-",
    which will throw and error. I played around with the "Convert" function some and I am thinking that a combination of the Convert and DateADD functions would be the way to accomplish this but I'm not sure.
    Basically what I need is using today's date as an example, I would need the result to return 04/10/14-04/09/15. Any assistance would be appreciated.

    This is not being used as a back-end to any type of user interface, so doing it on the front-end is not an option. The data is being exported out to text files, so it needs to be exactly as I had in the example as a single field.
    Thanks all for the feedback. Latheesh's post is the closest to what I need, in fact it's exactly what I'm looking for, which is below.
    Select Convert(varchar(20),DATEADD(mm, 1, GETDATE()),10 ) +' ---- '+ Convert(Varchar(20),DATEADD(mm, 12, GETDATE()),10)
    Ok, I got it working. Actually, turns out that it's not much different than Access syntax other than convert is used in place of Format. DateAdd, DateDiff, etc. are all used in Access as well. Thanks for all the help.

  • Using analytical function to calculate concurrency between date range

    Folks,
    I'm trying to use analytical functions to come up with a query that gives me the
    concurrency of jobs executing between a date range.
    For example:
    JOB100 - started at 9AM - stopped at 11AM
    JOB200 - started at 10AM - stopped at 3PM
    JOB300 - started at 12PM - stopped at 2PM
    The query would tell me that JOB1 ran with a concurrency of 2 because JOB1 and JOB2
    were running started and finished within the same time. JOB2 ran with the concurrency
    of 3 because all jobs ran within its start and stop time. The output would look like this.
    JOB START STOP CONCURRENCY
    === ==== ==== =========
    100 9AM 11AM 2
    200 10AM 3PM 3
    300 12PM 2PM 2
    I've been looking at this post, and this one if very similar...
    Analytic functions using window date range
    Here is the sample data..
    CREATE TABLE TEST_JOB
    ( jobid NUMBER,
    created_time DATE,
    start_time DATE,
    stop_time DATE
    insert into TEST_JOB values (100, sysdate -1, to_date('05/04/08 09:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 11:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (200, sysdate -1, to_date('05/04/08 10:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 13:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (300, sysdate -1, to_date('05/04/08 12:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 14:00:00','MM/DD/YY hh24:mi:ss'));
    select * from test_job;
    JOBID|CREATED_TIME |START_TIME |STOP_TIME
    ----------|--------------|--------------|--------------
    100|05/04/08 09:28|05/04/08 09:00|05/04/08 11:00
    200|05/04/08 09:28|05/04/08 10:00|05/04/08 13:00
    300|05/04/08 09:28|05/04/08 12:00|05/04/08 14:00
    Any help with this query would be greatly appreciated.
    thanks.
    -peter

    after some checking the model rule wasn't working exactly as expected.
    I believe it's working right now. I'm posting a self-contained example for completeness sake.I use 2 functions to convert back and forth between epoch unix timestamps, so
    I'll post them here as well.
    Like I said I think this works okay, but any feedback is always appreciated.
    -peter
    CREATE OR REPLACE FUNCTION date_to_epoch(p_dateval IN DATE)
    RETURN NUMBER
    AS
    BEGIN
    return (p_dateval - to_date('01/01/1970','MM/DD/YYYY')) * (24 * 3600);
    END;
    CREATE OR REPLACE FUNCTION epoch_to_date (p_epochval IN NUMBER DEFAULT 0)
    RETURN DATE
    AS
    BEGIN
    return to_date('01/01/1970','MM/DD/YYYY') + (( p_epochval) / (24 * 3600));
    END;
    DROP TABLE TEST_MODEL3 purge;
    CREATE TABLE TEST_MODEL3
    ( jobid NUMBER,
    start_time NUMBER,
    end_time NUMBER);
    insert into TEST_MODEL3
    VALUES (300,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 19:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (200,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 12:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (400,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 14:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (500,date_to_epoch(to_date('05/07/2008 11:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 16:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (600,date_to_epoch(to_date('05/07/2008 15:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 22:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (100,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 23:00','MM/DD/YYYY hh24:mi')));
    commit;
    SELECT jobid,
    epoch_to_date(start_time)start_time,
    epoch_to_date(end_time)end_time,
    n concurrency
    FROM TEST_MODEL3
    MODEL
    DIMENSION BY (start_time,end_time)
    MEASURES (jobid,0 n)
    (n[any,any]=
    count(*)[start_time<= cv(start_time),end_time>=cv(start_time)]+
    count(*)[start_time > cv(start_time) and start_time <= cv(end_time), end_time >= cv(start_time)]
    ORDER BY start_time;
    The results look like this:
    JOBID|START_TIME|END_TIME |CONCURRENCY
    ----------|---------------|--------------|-------------------
    100|05/07/08 09:00|05/07/08 23:00| 6
    200|05/07/08 09:00|05/07/08 12:00| 5
    300|05/07/08 10:00|05/07/08 19:00| 6
    400|05/07/08 10:00|05/07/08 14:00| 5
    500|05/07/08 11:00|05/07/08 16:00| 6
    600|05/07/08 15:00|05/07/08 22:00| 4

  • Function module for getting periods for date range

    Hi,
    Can anybody tell me the function module which will return the periods along with the year, when we give a date range.
    e.g
    01011999 to 120112000
    so it shoud return peroids between these date with year. Its possible thru programatically, but i m checking if there is any FM, so i can use FM.
    Thanks,

    Hi,
    You can use function module which works exactly what you are expecting FIMA_DAYS_AND_MONTHS_AND_YEARS.
    please reward points to useful answers.
    Thanks,
    Sriram Ponna.

  • EasyDMS - search by date range for characteristics of type date

    Hi Folks,
    I have a characteristic of type date in the additional data of a DMS document. If I enter the date (for example validity date) as 08/31/2009 and search using cv04n and give a date range for the characteristic (i.e. 01/01/2009 - 12/31/2009), the search result will bring up the document.
    However, I cannot do this from the EasyDMS find function. I need to specify an exact date. This is not very helpful for user who need to find documents with a validity date between 01/01/2009 - 12/31/2009 for example. Is there a way users can search for date range in EasyDMS find function?
    Thanks,
    Lashan

    To search a date range with EasyDMS Client you have to set the registry key
    \HKEY_CURRENT_USER\Software\SAP\EasyDms\Generel\DateSearchPick to Value 0
    Then you can use the input field like in SAP-Gui. (01.01.2009-31.01.2009)
    If you set the value to 1 or the key is not defined you can only search for one specified date.
    If you don't find this key on your PC create it as dword.
    Maybe you must restart you PC for takeing effect.
    Hope this will help you.
    Regards Wolfgang

  • Getting Record Count From Date Range - IDE: PLSQL Developer

    I would like to count the number of member records that fall within a specified date range based on the members effective and expiration dates and their 'elg_code'. I have posted the SQL for some sample data. What I would like to see returned is three columns of counts where the members eff_date exp_date fall within the date range specified by the SQL and have an Elg_code of ' ' (one blank space).
    So, what I would like is all members with elg_code ' ' where there eff_dt and exp_dt range falls within APR 2012, MAY 2012 & JUN 2012. So, based on the sample data I posted, Mark, where his elg_code record is ' ', his eff_dt is 1/1/2011 and his exp_dt is within APR 2012 (4/30/2012). Mark's range falls within APR 2012, but not MAY or JUNE of 2012. Marty would tally for both APR and MAY since his eff_dt is before MAY 2012 and his exp is within MAY 2012. etc..
    Based on the data below, the results should look like:
    APR MAY JUN
    4 3 2
    APR should have FRANK, MARK, MARTY, MARY,
    MAY should have FRANK, MARTY, MARY
    JUN should have FRANK and MARY
    NOAM and JEAN should not show up as their records with elg_code ' ' do not have eff_dt and exp_dt records that fall within APR-JUN 2012.
    So what I tried without success as it appears I have some kind of Cartesian issue (?), is:
    select count(m1.mbr_name) APR,
    count(m2.mbr_name) MAY,
    count(m3.mbr_name) JUN
    from mbr2 m1,
    mbr2 m2,
    mbr2 m3
    where m1.eff_dt < '01-may-2012'
    and m1.exp_dt > '01-apr-2012'
    and m1.elg_code = ' '
    and m2.eff_dt < '01-jun-2012'
    and m2.exp_dt > '01-may-2012'
    and m2.elg_code = ' '
    and m3.eff_dt < '01-jul-2012'
    and m3.exp_dt > '01-jun-2012'
    and m3.elg_code = ' '
    Below is the DML
    Thanks for any assistance!
    create table mbr2 (mbr_name varchar(10), grpid varchar(1), eff_dt date, exp_dt date, elg_code varchar(1))
    commit
    insert into mbr2 values ('MARK', 'A', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('04-30-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('MARK', 'A', to_date('05-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('MARTY', 'A', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('05-31-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('MARTY', 'A', to_date('06-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('FRANK', 'B', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('06-30-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('FRANK', 'B', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('MARY', 'B', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('06-30-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('MARY', 'B', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('JEAN', 'C', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('07-01-2011', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('JEAN', 'C', to_date('07-01-2011', 'MM-DD-YYYY'), to_date('01-01-2012', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('NOAM', 'D', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), ' ')
    commit

    Hi,
    Here's one way:
    WITH     all_months     AS
         SELECT     LEVEL                         AS month_num
         ,     ADD_MONTHS (first_month, LEVEL - 1)     AS month_begin
         ,     ADD_MONTHS (first_month, LEVEL)           AS next_month_begin
         FROM     (
                   SELECT  TO_DATE ('04-01-2012', 'MM-DD-YYYY')     AS first_month
                   ,     TO_DATE ('06-01-2012', 'MM-DD-YYYY')     AS last_month
                   FROM     dual
         CONNECT BY     level     <= 1 + MONTHS_BETWEEN (last_month, first_month)
    SELECT    COUNT (CASE WHEN month_num = 1 THEN 1 END)     AS month_1
    ,       COUNT (CASE WHEN month_num = 2 THEN 1 END)     AS month_2
    ,       COUNT (CASE WHEN month_num = 3 THEN 1 END)     AS month_3
    FROM       all_months  a
    JOIN       mbr2        m  ON  a.month_begin       <= m.exp_dt
                            AND a.next_month_begin      >  m.eff_dt
    WHERE     m.elg_code      = ' '
    ;This assumes you know how many months will be in the output. If you want to derive that from the data, or to give the columns meaningful aliases (such as APR-2011 instead of MONTH_1), then you'll need dynamic SQL (to get separate columns for each month) or string aggregation (if you don't mind one big VARCHAR2 column, formatted to look like several columns). See {message:id=3527823}
    If you don't mind modifying the query a little every time you run it, you can hard-code the number of columns and the month names. In the main query, put exactly as many lines as you need, with the alias you want at the end. That is, instead of
    ,       COUNT (CASE WHEN month_num = 2 THEN 1 END)     AS month_2say
    ,       COUNT (CASE WHEN month_num = 2 THEN 1 END)     AS may_2012I'm not sure exactly what the problem was with the query you posted. It looks like this site cut off parts of the query.
    One thing that is definitely a mistake is that you're comparing DATE columns to VARCHAR2 literals. Never compare a DATE to a VARCHAR2; compare DATEs to DATEs (or compare VARCHAR2s to VARCHAR2s). So instead of
    and m1.exp_dt > '01-apr-2012'you should say
    and m1.exp_dt > TO_DATE ('01-apr-2012', 'dd-mon-yyyy')Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.
    Edited by: Frank Kulash on Jun 26, 2012 3:32 PM

  • Date range validity evaluation in BRM table

    Lectori salutem, Gurus salutem,
    I'm using 7.3 sp03. I would like to achieve the following with BRM (bit simplified):
    a parameter, ABC, is passed to a ruleSetService, and needs to be evaluated.
    The table is as follows:
    ABC startDate endDate Value
    1 01-01-2011 31-12-2011 A
    1 01-01-2012 31-12-2012 B
    2 01-01-2011 31-12-2011 X
    4 01-01-2012 31-12-2012 Y
    When ABC-value '1' is passed to the ruleSetService in the table the first row needs to be selected. CurrentDate (24-11-2011) is in between 01-01-2011 and 31-12-2011, making this the valid row. The value that should be returned is A.
    Beginning of next year it should change to B.
    How should I set this up in BRM?
    Thanks in advance!
    Martijn.

    Hi Martijn,
    Appreciate that you've simplifiied the scenario... but do you have any idea how many of these entries you are likely to have in total as that may change the answer.
    You have a couple of choices that might work here...
    1. You could a decision table... to hold your values (i.e. ABC and date range as conditions, value as action) and use the rule that evaluates the decision table to pick up the current date for the comparison. e.g.  date conditions would be "greater than than 01-01-2011", "less than 31-12-2011", etc.
    2. Alternatively, if the plan is to have a simple end of year change over,  you could use Effectivities (in the Project Resources of the rules project) to determine which values  are selected and use a decision table or even just a rule script to determine the value.
    But the thing is... HOW you organise your rule is going to depend a lot on:
    a) How many entries in total do you expect
    b) Is there a nice neat cutover of all ABC values at the same time or do effective date ranges vary a lot between different ABC values
    c) Who's responsible for maintaining these and if multiiple people are responsible do you need to organise your rule to cater for that? E.g. Are different people responsible for different ABC entries
    Does that help at all?
    Regards,
    Jocelyn

Maybe you are looking for

  • Installing Officejet 4315v on Windows Vista Home Premium will not install with/without disc.

    I have Windows Vista Home Premium S.P.1, having difficulty installing my  Officejet 4315v.   My HP computer died and I replaced with this one. I wasn't have problems until just recently. I tried running the disc I have but it just says 98,2000,XP, CD

  • BOM Parent / Child

    Hi, in previously versions (2004) a BOM (old type assembly) was shown in a sales document (sales order) only with the parent item. In 2007, a BOM (type sales) all, parent and child are listed in a sales order, where the item-number of the parent is r

  • BUG or ER - Editing the "Launch Settings - Java Options"

    Project Properties : Run/Debug/Profile : Edit : Launch Settings : Java Options I changed added -Djps.auth.debug=false -Djps.auth.debug.verbose=false Is it normal that I've to restart WebLogic to get the change applied ? I feel it should be applied th

  • Need Info or a Solution for FTP Firewall

    I have been able to create an Applesque anonymous FTP login situation for PCs and the only problem left is that the PCs can not connect unless they turn off Passive FTP. For some reason ports 20-21 are being inappropriately blocked to proper FTP comm

  • CS5 Bridge does not recognise Nikon D 800 Raw Files

    I have Photoshop CS5 Version 12.0 (x64). Photoshop recognises Nikon D 800 Raw files BUT Bridge does not. I have tried updates but my Apple Mac Pro does not recognise them