Default date range of BBPCF02

Folks -
I am trying to find a simple way to change the default date range shown when the iview is called   - Currently that is "Last 7 days"  - User can use drop down to chsnge to "Last 30 days."  But, is there a way to change the default?
SRM 5.0, iview on EP7 SP11 Portal
Thanks in advance.
- David
Edited by: David Karpman on Apr 15, 2008 7:39 AM
Edited by: David Karpman on Apr 15, 2008 7:39 AM

Sorry, just noticed you put SRM 5 in your initial question.
This is strange, we have SRM 5 as well as 4 (we are upgrading now) and the BADI is available, we are using it.
You are definitly going to SE18 in the SRM client?
Which support pack of SRM 5 are you on? We are on 11 in SRM 5. Maybe one of the support packs added it to SRM 5?

Similar Messages

  • How do I change the default "date range" when searching in the forums?

    Hi all,
    New to the SAP forums...  How do I change the default date range when searching in the forums?  I am getting a 90 day search by default.  Then I have to change it and search again.  Argh!
    Thanks,
    --Amy Smith

    Hi Amy,
    the default date range cannot be changed by users. It is defined system-wide.
    Regards,
    Michael

  • Setting default date range in selection screen when executing as batch job.

    Hi Guys,
    I have one report to be scheduled as weekly batch job and one of the selection screen field is date range. If i set this report to run today then the date range will be from one week back date(Lower value) to today date(Higher value). When it runs for next week(Already scheduled as weekly batch job) the date range should be like this
    Lower value = today date
    higher value= next week run date.
    How can i achieve this functionality. Is it possible through Dynamic variant concept?. Rest of the selection screen fields have some default values and should not change.
    <REMOVED BY MODERATOR>
    Thanks in advance,
    Vinod.
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 3:52 PM

    Hi Vinod,
    Would suggest you to this.
    Create two parameters : p_start_date and p_end_date of type sy-datum on your selection screen , instead of a range.
    Now goto create a variant from SE38 for the report.
    While creating the variant, mark the "Selection Variable" checkbox for the two parameters and click on "Selection Variables".
    Select the option "D: Dynamic date calculation" for both the date fields.
    For p_start_date - select the option "Current Date"
    For p_end_date  - select the option "Current date +/- ??? days" and put 7 in the pop up.
    Hence what you have done now is, set up a dynamic variant, where p_start_date will have sy-datum and p_end_date will have sy-datum + 7, everytime the job runs.
    Now, in the program, first step after START-OF-SELECTION code the following:
    RANGES: r_date FOR sy-datum.
    start-of-selection.
    refresh r_date.
    r_date-sign = 'I'. r_date-option = 'BT'.
    r_date-low = p_start_date. r_date-high = p_end_date.
    append r_date.
    Hence this way, you would have built your range and use it as needed.
    Cheers,
    Aditya

  • VL10h - 1 month default delivery date range

    Dear Sirs,
    I am using VL10h to create deliveries from Sales Order. But, The default date range it takes is only 1 month. Would you please suggest me to increase the date range?
    The message I am getting is-
    Latest deliv. creation date (04.12.2009) further in future than allowed (30 days)
    Message no. V50R014
    Diagnosis
    Maximum future delivery time frame was exceeded.
    System Response
    In your system, the maximum delivery creation time frame is limited to 30 days in the future. However, you want to deliver until 04.12.2009, which the system does not allow.
    Procedure
    Choose a smaller interval for delivery.
    Procedure for System Administration
    You can set the number of days in the future the delivery is limited to in Customizing in Create deliveries profiles 0101, which is assigned to the current list profile "Sales Order and Purchase Order Items".
    regards,
    rahul

    Dear Rahul
    To avoid the error message V50R014 you have to change the value of the
    field "Maximum delivery period in the future"  (transaction VL10CUC).  Alternatively, maintain the delivery creation profile in transaction VL10H for the field "Maximum delivery period in the future".
    Hope this helps.
    Regards
    Tonia

  • Problem with customer exit variable on date range

    Hi All,
    I have customer exit variable on date range. In the selection screen it has to give the week range  as a default (05/21/2009 to 05/27/2009).
    Earlier its working fine and from yesterday onwards it is not working properly. yesday onwards default date range was not displaying in selection screen.
    Wht would be the problem.
    Thanks in Advance

    Hi Ashish,
    I checked every thing what u told earlier. Every thing is fine.
    And another thing is
    I have routine in infopackage level. Since day before yesterday it was working fine and yesterday onwards it was not working.
    Eg: budat will take the data based on routine for the week. But yesterday onwards it is not picking up the data.however I have the data in datasource for the week.
    Wht would be the problem. I debuged the code and its working fine.
    Sekhar

  • SqlQuery Help [date range]

    Database: Oracle 10g
    Table: SOURCE_TABLE
    #of records: 500k
    Primary Key: ID, EFF_DATE
    Data/Table:
    with SOURCE_TABLE AS
         (select 'P1' AS ID, TO_DATE('03/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V1' AS VALUE1, 'V2' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P1' AS ID, TO_DATE('02/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V3' AS VALUE1, 'V24' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID, TO_DATE('01/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID, TO_DATE('03/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V11' AS VALUE1, 'V21' AS VALUE2 FROM DUAL)                                 
    SELECT * FROM SOURCE_TABLE  Conditions:
    For a given date range i.e. 01/01/2012 to 04/30/2012
    what we need is: For each ID, we need part "P" value1 and value2 column values for each specific month between the default date ranges.
    In this case it would be Jan-2012, FEB-2012, MAR-2012, APR-2012
    If you see below output for P1, there will not be JAN-2012 record as the part P1 is effective from FEB-2012
    What i have done so far:
    i have the select query basically it is looping through 01/2012 to 04/2012 and for every month,
    find out the max eff_date record less then the month that we are computing the value columns for
    Output:
    with output as
         (select 'P1' AS ID , '02/01/2012' AS AS_OF_DATE, 'V3' AS VALUE1, 'V24' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P1' AS ID , '03/01/2012' AS AS_OF_DATE, 'V1' AS VALUE1, 'V2' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P1' AS ID , '04/01/2012' AS AS_OF_DATE, 'V1' AS VALUE1, 'V2' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '01/01/2012' AS AS_OF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '02/01/2012' AS AS_OF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '03/01/2012' AS AS_OF_DATE, 'V11' AS VALUE1, 'V21' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '04/01/2012' AS AS_OF_DATE, 'V11' AS VALUE1, 'V21' AS VALUE2 FROM DUAL
    SELECT * FROM OUTPUT;
            ID     AS_OF_DATE     VALUE1     VALUE2
         P1     02/01/2012     V3     V24
         P1     03/01/2012     V1     V2
         P1     04/01/2012     V1     V2
         P2     01/01/2012     V10     V20
         P2     02/01/2012     V10     V20
         P2     03/01/2012     V11     V21
         P2     04/01/2012     V11     V21Thanks in advance

    Hi,
    ora1001 wrote:
    Hi frank,
    I changed the query to inner join instead of outer join because if a part is not effective for a given month, then i dont need a record.
    ex: if P1 EFF_DATE IS 03/01/2012, then i dont need records for JAN, FEB... You're right; inner join is all you need here. My mistake.
    What is "P1 EFF_DATE"? Is that the start of the date range you're interested in (January 1, 2012 in your original example)?
    Don't you still need to cosider rows before that date? For example, say we want to show the same 4 months (January to April, 2012), but instead of
    select 'P2' AS ID, TO_DATE('01/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUALthe data is changed to
    select 'P2' AS ID, TO_DATE('11/01/2011','MM/DD/YYYY') AS EFF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUALWould you still want the same results? In this example, the values from November 2011 serve as the values for January and Febrruay 2012. It doesn't matter that Noverber 2011 is outside of the target range.
    It works fine... its faster now.
    however, i would like to know the difference in my query vs your query in terms of performance..
    the subquery runs faster when compared to analytic function...
    select * from part p,
    source_table st
    where p.id = st.id
    and st.eff_date = (select max(eff_date) from source_table st1
    where st1.eff_date < '01-mar-2012');
    If st1.eff_date is a DATE, then don't try to compare it to a VARCHAR2, such as '01-mar-2012'. Use TO_DATE:
    where st1.eff_date < TO_DATE ( '01-mar-2012'
                                   , 'DD-mon-YYYY'
                        )or a DATE literal:
    where st1.eff_date < DATE '2012-03-01'instead.
    vs
    select * from (
    select p.id,
    st.eff_date,
    row_number() over (partition by st.id,st.eff_date order by st.id,st.eff_date desc) as consider_order from part p,
    source_table st
    where p.id = st.id) where consider_order = 1;
    The first approach is doing much less work. It just has to remember what the latest eff_date is. Say it has already found a row with March 1, 2012, and it comes across a row with an earlier date, such as January 1, 2012. As soon as it sees that January 1, 2012 is not the new record holder, it can move on to the next row. (Using the LAST function, as I suggested, would cause it to do even less work.)
    The second approach is doing much more work. It has to remember all the dates, in order. Say it has already found a row with March 1, 2012, and it comes across a row with an earlier date, such as January 1, 2012. After it sees that January 1, 2012 is not the new record holder, it still has to determine if January 1 comes 2nd, or 3rd on the list.

  • CR 2008: Setting currrentdate as default begin date in a date range paramet

    I have a Crystal Report with a date range parameter.
    How do I set the Begin Date to be todays date ?
    I am using a Universe as the data source.
    Thanks,

    Hi Rajesh,
    1) Is the prompt a constant value?
        If yes then type "1900/01/01" in the from value as default value. And in the report selection formula should look similar to this :
    DateVar DateParamValue:-
    If   = Date(1900,1,1)  Then
        DateParamValue := CurrentDate
    Else
        DateParamValue := {?DateParam};
        {Table.DateField} = DateParamValue;

  • How to make default values for date range?

    Dear Colleagues,
    My customer is asking for a default value for a date range prompt.
    The FromDate should contain the 1st of current month, the ToDate should contain current date.
    Does anyone have any idea how I can meet this demand?
    Regards Silje

    Hi Federico,
    Thank you for the answer, we are back to the challenge after summer vacations!
    I have created a variable in the universe: SELECT current date  as TODAY FROM SYSIBM.SYSDUMMY1. I Called it TODAY.
    Then I created a prompt in the query based on Date. In Prompt Properties I tagged for "Set Default Values" and I typed in TODAY.
    When I try to run the query I get the error message:  The date for the query filter based on 'Date' is invalid (WIS10704).
    What is wrong? What do I have to do differently?
    My goal is to have a default for Date that gives me today..
    Regards Silje

  • Can not set data range for a numerical control

    I want to set the maximum of data range to 5000, but it always went back to default value of 127.
    WHy I can not change the data range? Thanka for explanations.
    Message Edited by Dejun on 11-14-2007 11:47 PM
    Attachments:
    datarange.jpg ‏74 KB

    So hit the 'Representation' button.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Continious data range algorithm

    I have in my database table 2 important date columns: StartDate (Not null) and EndDate(Allowed Null).
    I want to ensure that all records in the table would always create perfect contiues date ranges with no holes inside.
    Wor example there may not be records [1-may..1-may, 3-may-...] because there would be a hole [2-may...2-may]. Holes are not allowed.
    And overlapping is not allowed, for example [1-may..1-may, 1-may-2may, 3-may-...] is not allowed because overlapping occures on day 1-may. Overlapping and holes are not allowed. But it is allowed that table has no records at all. But all DML manipulations with existing records must ensure that overlapping and holes won't occur.
    How to write such check? How to ensure that data ranges would stay continous with no holes and no overlaps?
    Oracle 11g.

    You're setting the wrong value for the start of a group when there is no (null) lagging end date. In my example I set the value to 0 when it was null as I was expecting each group to start at 1. In your case you've set the date to 1/1/1900 which isn't necessarily the day before the first start date of the group. Instead just default it to the start date - 1 to force a match...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1 as id, to_date('01.04.2013', 'DD.MM.YYYY') as val1, to_date('04.04.2013', 'DD.MM.YYYY') as val2 from dual union all
      2             select 1, to_date('05.04.2013', 'DD.MM.YYYY'), to_date('06.04.2013', 'DD.MM.YYYY') from dual union all
      3             select 1, to_date('07.04.2013', 'DD.MM.YYYY'), null from dual union all
      4             select 2, to_date('01.04.2013', 'DD.MM.YYYY'), to_date('03.04.2013', 'DD.MM.YYYY') from dual union all
      5             select 2, to_date('04.04.2013', 'DD.MM.YYYY'), to_date('07.04.2013', 'DD.MM.YYYY') from dual union all
      6             select 2, to_date('09.04.2013', 'DD.MM.YYYY'), to_date('12.04.2013', 'DD.MM.YYYY') from dual union all
      7             select 2, to_date('13.04.2013', 'DD.MM.YYYY'), null from dual union all
      8             select 3, to_date('01.04.2013', 'DD.MM.YYYY'),to_date('03.04.2013', 'DD.MM.YYYY') from dual union all
      9             select 3, to_date('04.04.2013', 'DD.MM.YYYY'), null from dual union all
    10             select 4, to_date('01.04.2013', 'DD.MM.YYYY'), to_date('01.04.2013', 'DD.MM.YYYY') from dual union all
    11             select 4, to_date('01.04.2013', 'DD.MM.YYYY'), null from dual
    12            )
    13  --
    14  select id
    15        ,val1 as "start"
    16        ,val2 as "end"
    17        ,lag(val2) over (partition by id order by val1)
    18        ,case when
    19             nvl(lag(val2) over (partition by id order by val1),val1-1) != val1-1 then
    20                   'hole or overlap'
    21              else null
    22         end as chk
    23  from t
    24* order by 1, 2
    25  /
            ID start                end                  LAG(VAL2)OVER(PARTIT CHK
             1 01-APR-2013 00:00:00 04-APR-2013 00:00:00
             1 05-APR-2013 00:00:00 06-APR-2013 00:00:00 04-APR-2013 00:00:00
             1 07-APR-2013 00:00:00                      06-APR-2013 00:00:00
             2 01-APR-2013 00:00:00 03-APR-2013 00:00:00
             2 04-APR-2013 00:00:00 07-APR-2013 00:00:00 03-APR-2013 00:00:00
             2 09-APR-2013 00:00:00 12-APR-2013 00:00:00 07-APR-2013 00:00:00 hole or overlap
             2 13-APR-2013 00:00:00                      12-APR-2013 00:00:00
             3 01-APR-2013 00:00:00 03-APR-2013 00:00:00
             3 04-APR-2013 00:00:00                      03-APR-2013 00:00:00
             4 01-APR-2013 00:00:00 01-APR-2013 00:00:00
             4 01-APR-2013 00:00:00                      01-APR-2013 00:00:00 hole or overlap
    11 rows selected.

  • Date range query  problem  in report

    Hi all,
    I have created a report based on query and i want to put date range selection but query giving problem.
    If i am creating select list selection then it is working fine means it will display all records on the particular date.
    But what i need is that user will enter date range as creation_date1,creation_date2 and query should return all the records between these date range. i want to pass it by creating items, i created two items and passing creation_date range to display all records but not displaying and if not passing date then should take null as default and display all records
    Here is the query:
    /* Formatted on 2006/12/10 20:01 (Formatter Plus v4.8.0) */
    SELECT tsh."SR_HEADER_ID", tsh."SALES_DEPT_NUMBER", tsh."COUNTRY",
    tsh."LOCAL_REPORT_NUMBER", tsh."ISSUE_DATE", tsh."SUBJECT",
    tsh."MACHINE_SERIAL_NUMBER", tsh."MACHINE_TYPE", tsh."MACHINE_HOURS",
    tsh."STATUS"
    FROM "TRX_SR_HEADERS" tsh, "TRX_SR_PARTS" tsp
    WHERE (tsh.status LIKE :p23_status_sp OR tsh.status IS NULL)
    AND (tsh.machine_type LIKE :p23_machine_type_sp)
    AND ( tsh.machine_serial_number LIKE
    TO_CHAR (:p23_machine_serial_number_sp)
    OR tsh.machine_serial_number IS NULL
    AND ( TO_CHAR (tsh.failure_date, 'DD-MON-YY') LIKE
    TO_CHAR (:p23_failure_date_sp)
    OR TO_CHAR (tsh.failure_date, 'DD-MON-YY') IS NULL
    AND ( TO_CHAR (tsh.creation_date, 'DD-MON-YY')
    BETWEEN TO_CHAR (:p23_creation_date_sp)
    AND TO_CHAR (:p23_creation_date_sp1)
    OR TO_CHAR (tsh.creation_date, 'DD-MON-YY') IS NULL
    AND (tsh.issue_date LIKE :p23_date_of_issue_sp OR tsh.issue_date IS NULL)
    AND (tsh.country LIKE :p23_country_sp OR tsh.country IS NULL)
    AND ( tsh.local_report_number LIKE TO_CHAR (:p23_local_rep_num_sp)
    OR tsh.local_report_number IS NULL
    AND ( tsp.part_number LIKE TO_CHAR (:p23_part_number_sp)
    OR tsp.part_number IS NULL
    AND tsh.machine_type IN (
    SELECT DISTINCT machine_type
    FROM trx_sales_dept_machine_list
    WHERE sales_department_id IN (
    SELECT DISTINCT sales_department_id
    FROM trx_user_sales_department
    WHERE UPPER (user_name) =
    UPPER ('&APP_USER.'))
    AND SYSDATE >= valid_from)
    AND tsh.sr_header_id = tsp.sr_header_id
    can any one tell me wat is wroung in this query.
    Any other way to write this?
    Thank You,
    Amit

    Hi User....
    Here is some date range SQL that my teams uses with some success:
    For date columns that do not contain NULL values, try this (note the TRUNC, it might help with your "today" problem).
    The hard coded dates allow users to leave the FROM and TO dates blank and still get sensible results (ie a blank TO date field asks for all dates in the future.
    AND TRUNC(DATE_IN_DATABASE)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),:
    :P1_DATE_TO)
    For date columns that contain NULL values, try this (a little bit trickier):
    AND nvl(TRUNC(DATE_IN_DATABASE),
    decode( :P1_DATE_FROM,
    decode( :P1_DATE_TO,
    TO_DATE('30-DEC-3000'),
    NULL),
    NULL)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),
    :P1_DATE_TO)
    Note the 30-DEC-3000 versus 31-DEC-3000. This trick returns the NULL dates when the FROM and TO date range items are both blank.
    I hope this helps.
    By the way, does anyone have a better way of doing this? The requirement is given a date column in a database and a FROM and a TO date item on a page,
    find all of the dates in the database between the FROM and TO dates. If the FROM date is blank, assume the user want all dates in the past (excluding NULL dates). If the TO date is blank, assume that the user wants all of the dates in the future (excluding NULL dates). If both FROM and TO dates are blank, return all of the dates in the databse (including NULL dates).
    Cheers,
    Patrick

  • Report for open invoice value against GR done within a date range

    Dear experts ,
    I need a report  between date ranges for which there is a GR done , but invoice is pending .
    Where can i get this ? 
    Regards
    Anis

    hi,
    You can  check few default PO reports wid proper paramater in it
    or
    Can check table EKBE
    or
    Check PO history in the PO doc
    Or
    Check the ME80FN
    Regards
    Priyanka.P

  • Support date range and as of date in Universe

    Hi,
    I have some questions on Universe design best practices. Can you please help ?
    We are using BO4 SP7 and UDT for universe design.
    Little bit on our schema: snow flake schema with multiple fact tables. Most of our table are 'Pure Type 6' dimension tables in which start date and end date are used to track historical data.  We also have date dimension table. We want to support both 'As of date' and custom 'date range' type reporting.
    Out typical use cases are like
    1. All items As of date
    2. All items between dates etc.
    How can we model it in the Universe ?
    1. We can not join every dimension with date_d dimension. So we have decided to put default conditions at Folder level. Our typical date conditions as below.
    date_d.end_full_date_utc  between  diminetion1_d.start_date AND diminetion1_d.end_date
    But problem is, table condition are not always applied. If we have A, B and C folders and if I create report by using objects from A and C then non of the condition applied to B appears in the query. This is problem for us.
    2. Other approach we thought is to define start and end prompt and define a restriction condition  for each and every table.
          diminetion1_d.start_date > [start_date_prompt] AND diminetion1_d.end_date < [end_date_prompt]
    We thought it will be too munch work as we have more than 150 tables and also 2 prompts will always appear, even of as of date, which may not look good.
    3. Is there a way apply to apply these date conditions at the individual table level so that they will appear in Query when ever the table is involved in the join path ?
    3. What is the best way to handle this kind of requirements, please suggest ?
    Thanks

    Hi,
    I have some questions on Universe design best practices. Can you please help ?
    We are using BO4 SP7 and UDT for universe design.
    Little bit on our schema: snow flake schema with multiple fact tables. Most of our table are 'Pure Type 6' dimension tables in which start date and end date are used to track historical data.  We also have date dimension table. We want to support both 'As of date' and custom 'date range' type reporting.
    Out typical use cases are like
    1. All items As of date
    2. All items between dates etc.
    How can we model it in the Universe ?
    1. We can not join every dimension with date_d dimension. So we have decided to put default conditions at Folder level. Our typical date conditions as below.
    date_d.end_full_date_utc  between  diminetion1_d.start_date AND diminetion1_d.end_date
    But problem is, table condition are not always applied. If we have A, B and C folders and if I create report by using objects from A and C then non of the condition applied to B appears in the query. This is problem for us.
    2. Other approach we thought is to define start and end prompt and define a restriction condition  for each and every table.
          diminetion1_d.start_date > [start_date_prompt] AND diminetion1_d.end_date < [end_date_prompt]
    We thought it will be too munch work as we have more than 150 tables and also 2 prompts will always appear, even of as of date, which may not look good.
    3. Is there a way apply to apply these date conditions at the individual table level so that they will appear in Query when ever the table is involved in the join path ?
    3. What is the best way to handle this kind of requirements, please suggest ?
    Thanks

  • Date Range Selection

    Dear friends,
    How to select the record from BSEG table between Date range. Please give me the solution . Am also try to find the solution in SDN also.
    select-options post_dt for bkpf-budat obligatory default sy-datum NO-EXTENSION.
    select belnr budat from bkpf into corresponding fields of table it_head
        where bukrs eq compcode
        and gjahr eq year
        and blart eq doctype
        and budat in post_dt
        order by belnr budat.
    For this select query is working in perfect for single date only. But i want to select the date date range wise.
    Thanks
    Saravanan R

    HI,
           U can check the Select Quert by using IN s_option.
    Like eg:--
        Select * form Zemp where empno in s_empno.
    Hope this example will help u...
    here Zemp is a table...... empno is a field     s_empno is a Select-option.
    Thanks and rEgards
    Suraj S Nair

  • 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

Maybe you are looking for

  • Create custom document with wrong size

    Hi, I have a problem (on Sun Solaris 5.8) when I create custom document with more than 10MB size. I've created an agent which detects the events on a custom data type MYDOCUMENT (extension .mydoc). When I put a new document test1.mydoc (size of 10MB

  • A Chink in the Armor

    Hi all, As I'm agonizing over which case to purchase for my 3Gs, I can't believe that there are popular cases out there that seems to ignore the obvious breaking point. Namely the front screen. I've seen many youtube videos on Mophie Juice Pack Air a

  • OC4J ContentType error

    Running a newly installed OC4J Instance and Web Forms 10.1.2.3.0 plus the latest OPatch patches, I am getting repeated error messages in the OC4J window when I start a form from the browser. The message is: 11/11/15 10:01:18 formsweb: The application

  • Is javascript in HTML e-mail possible ?

    Hi mates, I'm trying to send an HTML e-mail with a piece javascript code which is an Action handler for the buttons in the HTML mail. Using MailPackage in my mapping, I made sure that javascript and html code is rendered in the output XML message. Bu

  • ISE HA ordering question

    Hi, I cant seem to find any definitive answer regarding ISE software ordering in a HA deployment scenario If i'm proposing a HA ISE running on the secure network server (SNS-3495-K9) am i required to order the ISE software (SW-3495-ISE-K9)_ for both