Find gap between two dates from table

Hello All,
I want to find gap between two dates ,if there is no gap between two dates then it should return min(eff_dt) and max(end_dt) value
suppose below data in my item table
item_id    eff_dt           end_dt
10         20-jun-2012     25-jun-2012
10         26-jun-2012     28-jun-2012 There is no gap between two rows for item 10 then it should return rows like
item_id eff_dt end_dt
10 20-jun-2012 28-jun-2012
item_id    eff_dt           end_dt
12         20-jun-2012     25-jun-2012
12         27-jun-2012     28-jun-2012 There is gap between two rows for item 12 then it should return like
item_id eff_dt end_dt
12 20-jun-2012 25-jun-2012
12 27-jun-2012 28-jun-2012
I hv tried using below query but it giv null value for last row
SELECT   item_id, eff_dt, end_dt, end_dt + 1 AS newd,
         LEAD (eff_dt) OVER (PARTITION BY ctry_code, co_code, item_id ORDER BY ctry_code,
          co_code, item_id) AS LEAD,
         (CASE
             WHEN (end_dt + 1) =
                    LEAD (eff_dt) OVER (PARTITION BY ctry_code, co_code, item_id ORDER BY ctry_code,
                     co_code, item_id, eff_dt)
                THEN '1'
             ELSE '2'
          END
         ) AS new_num
  FROM item
   WHERE TRIM (item_id) = '802'
ORDER BY ctry_code, co_code, item_id, eff_dtI m using oracle 10g.
please any help is appreciate.
Thanks.

Use start of group method:
with sample_table as (
                      select 10 item_id,date '2012-6-20' start_dt,date '2012-6-25' end_dt from dual union all
                      select 10,date '2012-6-26',date '2012-6-26' from dual
select  item_id,
        min(start_dt) start_dt,
        max(end_dt) end_dt
  from  (
         select  item_id,
                 start_dt,
                 end_dt,
                 sum(start_of_group) over(partition by item_id order by start_dt) grp
           from  (
                  select  item_id,
                          start_dt,
                          end_dt,
                          case lag(end_dt) over(partition by item_id order by start_dt)
                            when start_dt - 1 then 0
                            else 1
                          end start_of_group
                    from  sample_table
  group by item_id,
           grp
  order by item_id,
           grp
   ITEM_ID START_DT  END_DT
        10 20-JUN-12 26-JUN-12
SQL> SY.

Similar Messages

  • Gap Between Two Dates

    Can Anyone tell me how to find out the gap between two dates. Specifically Without counting Saturday and Sunday.

    corlettk wrote:
    <intercession>
    Has anyone written a DateMath class?... it would be handy... the amount (and ugliness) of the code required to do elementary date mathematics with the raw Calendar is appaling.<recess>
    Isn't Java 7 supposed to cure all this headache?
    </recess>

  • To find difference between two dates

    Hi all,
    I am new to this forum and oracle.
    I want to get the difference between two dates. My query is as below...
    sqlserver_utilities.datediff('YY', startdate,enddate)
    I want the difference in year.
    Please help me. It's really urgent.
    Thanks in advance.
    Regards,
    Inam

    Select to_char(enddate,'YY') - to_char(startdate,'YY') fromPLEASE don't do that. There are so many things wrong with it...
    for example:
    1). Why are you subtracting character data types?
    2). What if the start date is 1999 and the end date is 2000? Do you expect to get a difference of -1?
    3). What if the start date is 1 Jan 2000 and the end date is 31 Dec 2000? Do you expect to get 0 instead of 1 or .997?
    4). Why would you convert dates to something else when they are inherently subtractable.
    5). There are obvious points in the OP's "specification" that are vague - the best thing (after telling them to search, of course since this has been answered a million times already) would be to try to clarify the spec.
    John

  • Need help with finding diff between two dates

    Hi,
    could someone please point me in the right direction.
    I want to substract two dates to get the age of a person. One of the date is sysdate and the other is date of birth. Assuming we remove the time part of the date.
    Best Regards,

    Hi,
    select
    timestamp, sysdate,
    decode(sign(sysdate-timestamp - 1/24), -1,
    round(24*60*(sysdate-timestamp)) || ' minutes old ',
    decode(sign(sysdate-timestamp - 1), -1,
    round(24*(sysdate-timestamp)) || ' hours old ',
    decode(sign(sysdate-timestamp - 14), -1,
    trunc(sysdate-timestamp) || ' days old ',
    decode(sign(sysdate-timestamp - 60), -1,
    trunc((sysdate-timestamp)/7) || ' weeks old ',
    decode(sign(sysdate-timestamp - 365), -1,
    round(months_between(sysdate,timestamp)) || ' months old ',
    round(months_between(sysdate,timestamp)/12,1) || ' years old '
    ))))) age
    from t;
    Regards

  • Months between two date

    There two ways of finding months between two dates
    ROUND((Date1 – Date2) / 365.25 * 12,2) and
    ROUND(months_between(date1,date2),2) There is a slight difference between output from these two.
    I think the result from the second statement should be more accurate, confirm?
    Abhishek

    AbSHeik wrote:
    There two ways of finding months between two dates
    ROUND((Date1 – Date2) / 365.25 * 12,2) and
    ROUND(months_between(date1,date2),2) There is a slight difference between output from these two.
    I think the result from the second statement should be more accurate, confirm?
    AbhishekHi Abhishek,
    I also agree with this.
    Coz 365.25 = (365 + (1/4))
    This 0.25 actually the extra year of a Leap Year, distributed equally among 4 years. But, when the 1st formula is evaluated, the calculation might cause difference...
    So as far as Oracle is concerned, MONTHS_BETWEEN should be used.
    Please rectify me if i'm wrong.
    Ranit B.

  • Select entries between two dates by converting Unix timestamp in Oracle Dat

    Hi,
    I need to select the entries between two dates from an Oracle db. The Oracle db has a column with Unix timestamps. I use the following querry, but it doesnt seem to be working as desired.
    select count(*) from reporter_status where to_char(FIRSTOCCURRENCE, 'mm-dd-yy') between ('08-07-06') and ('08-08-06');
    FIRSTOCCURRENCE has the Unix timestamps.
    Could anyone help me out with this. Thank you for your help.

    Assuming that it is actually a UNIX timestamp, then it is the number of seconds since Jan 1, 1970, so you need something like:
    SELECT COUNT(*)
    FROM reporter_status
    WHERE TO_DATE('01-Jan-1970', 'dd-mon-yyyy') + (firstoccurrence/24/60/60)
                    BETWEEN TO_DATE('08-07-2006', 'mm-dd-yyyy') AND
                            TO_DATE('08-08-2006, 'mm-dd-yyyy');Did Y2K not teach us anything? Use 4 digit years.
    John

  • SQL Lead & Lag to find gap between dates

    i have a table with two columns event_start and event_end :
    CREATE TABLE MYBATCHTAB
      EVENT_START  DATE                             NOT NULL,
      EVENT_END    DATE                             NOT NULL
    and my data is :
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 22:45:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 23:55:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 15:30:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 17:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 16:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 17:30:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 20:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 22:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Event Start
    Event End
    08/12/2013 15:30:00
    08/12/2013 17:00:00
    08/12/2013 16:00:00
    08/12/2013 17:30:00
    08/12/2013 20:00:00'
    08/12/2013 22:00:00
    08/12/2013 22:45:00
    08/12/2013 23:55:00
    and i want to find the first whole start - end period in this example start : 15:30 - end 17:30 (merging  record 1&2 )
    but not the third one for example not 15.30 - 22:00 or not 15.30 23:55 because there are gaps between end dates.
    how can i do this using lead&lag ? 
    I'm not sure if this is the best approach

    Maybe a baby-step solution
    select event_start,event_end
      from (select event_start,
                   case when overlap is not null
                        then case when lead(overlap,1) over (order by event_start) is not null
                                  then lead(event_end,1) over (order by event_start)
                                  when lag(overlap,1) over (order by event_start) is not null
                                  then null
                             end
                        else event_end
                   end event_end
              from (select event_start,event_end,
                           case when lead(event_start,1) over (order by event_start) <= event_end
                                  or lag(event_end,1) over (order by event_start) >= event_start
                                then 'overlap'
                           end overlap
                      from mybatchtab
    where event_end is not null
    order by event_start
    EVENT_START
    EVENT_END
    08/12/2013 15:30:00
    08/12/2013 17:30:00
    08/12/2013 20:00:00
    08/12/2013 22:00:00
    08/12/2013 22:45:00
    08/12/2013 23:55:00
    or when there can be more than two consecutive overlaps
    select event_start,
           event_end
      from (select case when lag_overlap is null
                        then event_start
                   end event_start,
                   case when coalesce(lead_overlap,lag_overlap) is null
                        then event_end
                        when lag_overlap is null and lead_overlap is not null
                        then lead(event_end) over (order by event_start)
                    end event_end
              from (select event_start,event_end,
                           case when event_start < lag(event_end) over (order by event_start)
                                then 'overlap'
                           end lag_overlap,
                           case when event_end > lead(event_start) over (order by event_start)
                                then 'overlap'
                           end lead_overlap
                      from mybatchtab
             where lead_overlap is null
                or lag_overlap is null
    where event_end is not null
       and event_end is not null
    order by event_start
    Regards
    Etbin

  • Find the difference between two dates for the specific month and year

    Hi,
    I have two dates, start date is 30/12/2012 and end date is 04/01/2013. Using datediff I found the difference of days between two dates. But I find the no of days in January 2013. ie output is 4 instead of 6. I input month and year to find the no of days
    for that date. In this case I input Jan 2013. How can I sql this ?

    I don't understand how most of the answers provided here not analytically solving the problem with many cases possible.
    First let me understand you:
    You have 2 dates range and you want to calculate day range for specific month and year between the original date range.
    declare @for_month int = 1 --January
    declare @for_year int = 2013
    declare @StartDate date = '2012-12-20'
    declare @EndDate date = '2013-01-04'
    SELECT
    CASE
    WHEN (DATEPART(MONTH, @StartDate) = @for_month and DATEPART(MONTH, @EndDate) = @for_month) and ((DATEPART(YEAR, @StartDate) = @for_year or DATEPART(YEAR, @EndDate) = @for_year)) THEN
    DATEDIFF(DAY, @StartDate,@EndDate)
    WHEN (@StartDate < cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (@EndDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, DATEADD(MONTH, DATEDIFF(MONTH, -1, @EndDate)-1, 0),@EndDate)
    WHEN (@EndDate > cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) and (@StartDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, @StartDate,DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, @StartDate) + 1, 0))) + 1
    WHEN ((DATEDIFF(DAY, @StartDate, cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) >= 0) and (DATEDIFF(DAY, cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date), @EndDate) >= 0)) THEN
    DATEDIFF(DAY, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime), DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime)) + 1, 0))) + 1
    ELSE
    0
    END as [DD]
    I don't know how you calculate day range between 01/01/2013 and 04/01/2013
    is 4, it is actually is 3 but if that is the case, you can add 1 from the condition.

  • Select Between two date ranges from xml file

    Hi ,
    I have a column date_ with datatype VARCHAR2(150) it stores
    data as
    05/19/2010 11:23 AM
    05/20/2010 12:23 PM
    05/22/2010 11:23 AM
    05/25/2010 11:23 AM
    i have to select all the rows between 05/19/2010 and 05/22/2010 how to do that this column is in xml file

    I have a table wit two fields
    Field1 is integer and field2 is xmltype
    in the xmltype i store an xml file
    <ParentNode>
    <Node>
    <Cat>1</Cat>
    <Date>05/19/2010 11:23 AM </Date>
    </Node>
    <Node>
    <Cat>2</Cat>
    <Date>05/20/2010 12:23 PM </Date>
    </Node>
    <Node>
    <Cat>3</Cat>
    <Date>05/22/2010 11:23 AM </Date>
    </Node>
    </Parentnode>
    I am using teh below query to retrive teh result
    SELECT T.Feild1, XML.* FROM Tablename T,
    XMLTable( 'Parentnod/Node' PASSING T.Feild2 COLUMNS Cat NUMBER PATH 'Cat' ,
    DATE_ VARCHAR2(100) PATH 'Date'
    )XML where cat >1;
    now i have to do teh same to select the rows between two date range 05/19/2010 and 05/21/2010
    hope i am able to make teh question simple

  • Find Exact number of days between two dates

    How can get the exact number of days between two dates?

    An example of business days calculation in SQL */
    /* The algorythm is: */
    /* 1) Take the absolute difference between the dates */
    /* to_date('&todate') - to_date('&frdate') */
    /* 2) Subtract the weekends (number of weeks in the range */
    /* TRUNC(to_date('&todate'),'D') = 1st day of week that */
    /* end of period is in */
    /* TRUNC(to_date('&frdate'),'D') = Last day of week that */
    /* start of period is in */
    /* So subtracting these two gives the number of days */
    /* between the two dates but including all of the days in */
    /* the weeks that the dates start and end in. When this */
    /* number is divided by 7 it gives the number of weeks. */
    /* Multiplying by 2 gives the number of weekend days.     */
    /* 3) Subtract 1 day if the ending date is on a saturday */
    /* DECODE(to_char(to_date('&todate'),'D'),7,-1,0) */
    /* --> If the day of the week is saturday (7), returns -1 */
    /* 4) Subtract 1 day if the start date is on a sunday */
    /* DECODE(to_char(to_date('&frdate'),'D'),1,-1) */
    /* --> If the day of the week is sunday (1), returns 1 */
    /* 5) Add one day to make the range inclusive (The '1 + ' ) */
    /* Author: Kenneth Atkins ([email protected]) */
    /* http://www.olywa.net/katkins/oratip */
    define frdate = '&1'
    define todate = '&2'
    set verify off
    select      
         '&frdate' From_Date
         ,'&todate' To_Date,
         1 + to_date('&todate') - to_date('&frdate') -
         ((TRUNC(to_date('&todate'),'D') - TRUNC(to_date('&frdate'),'D'))/7)*2
         + DECODE(to_char(to_date('&todate'),'D'),7,-1,0)
    + DECODE(to_char(to_date('&frdate'),'D'),1,-1,0) Business_Days
    from dual
    Here is an example of running the script:
    SQL> @busdays 01-AUG-96 15-AUG-96
    FROM_DATE TO_DATE BUSINESS_DAYS
    01-AUG-96 15-AUG-96 11

  • Average of a field between two dates

    Hi,
    I have a table with two fields. Date Field and Percentage field. For ex,
    Date Percentage
    1/1/2006 11
    1/4/2006 23
    2/4/2006 34
    11/11/2006 354
    1/4/2007 75
    10/09/2007 67
    2/3/2008 876
    I want to find the average(sum of percentage/total no) of Percentage field between two dates.
    I am passing only the end date. And, the start date I have to find according to the end date.
    For ex,if I am passing the end date as 10/09/2007, starting date should be 1/4/2007.
    And, if I am passing the end date as 11/11/2006, starting date should be 1/4/2006.
    For end date 2/3/2008, start date should be 1/4/2007.
    Starting date is taken as by considering the year end as April to March. So, I have to retrieve the average of the percentage field from April to the selected date as end date.
    thanks

    Getting the sum, number of rows and average since the last 1st of April to the current date :
    SQL> with tbl as
      2  (select to_date('01/01/2006','dd/mm/yyyy') as dt, 11  prct from dual union all
      3   select to_date('01/04/2006','dd/mm/yyyy') as dt, 23  prct from dual union all
      4   select to_date('02/04/2006','dd/mm/yyyy') as dt, 34  prct from dual union all
      5   select to_date('11/11/2006','dd/mm/yyyy') as dt, 354 prct from dual union all
      6   select to_date('01/04/2007','dd/mm/yyyy') as dt, 75  prct from dual union all
      7   select to_date('10/09/2007','dd/mm/yyyy') as dt, 67  prct from dual union all
      8   select to_date('02/03/2008','dd/mm/yyyy') as dt, 876 prct from dual)
      9  select dt, prct,
    10         sum(prct) over (order by dt range between dt-add_months(trunc(add_months(dt,-3),'yyyy'),3) preceding and current row) sum_prct,
    11         count(prct) over (order by dt range between dt-add_months(trunc(add_months(dt,-3),'yyyy'),3) preceding and current row) nb_prct,
    12         avg(prct) over (order by dt range between dt-add_months(trunc(add_months(dt,-3),'yyyy'),3) preceding and current row) avg_prct
    13  from tbl;
    DT             PRCT   SUM_PRCT    NB_PRCT   AVG_PRCT
    01/01/06         11         11          1         11
    01/04/06         23         23          1         23
    02/04/06         34         57          2       28,5
    11/11/06        354        411          3        137
    01/04/07         75         75          1         75
    10/09/07         67        142          2         71
    02/03/08        876       1018          3 339,333333
    7 rows selected.Nicolas.

  • Query between two date columns ?

    Oracle 11g R2
    I'm trying too create a query between two date columns. I have a view that consists of many columns. There are two columns in question called valid_to and valid_from
    Part Number     Valid_from        valid_to
    100                    01/01/2000       01/01/9999
    200                    01/01/2000       01/01/9999
    300                    01/01/2000       01/01/9999
    etc
    If I want to only see rows between with a date range of 01/01/2000 and 01/01/2013 how can I put this as SQL ?
    Thanks in advance

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    See the forum FAQ: https://forums.oracle.com/message/9362002
    If you want to find rows that have that exact range, then you can do  something like
    SELECT  *
    FROM    table_x
    WHERE   valid_from  = DATE '2000-01-01
    AND     valid_to    = DATE '2013-01-01'
    If you want to find rows where any or all or the range on the row overlaps any or all of the 200-2013 target range, then
    SELECT  *
    FROM    table_x
    WHERE   valid_from  <= DATE '2013-01-02
    AND     valid_to    >= DATE '2000-01-01'
    If you want rows that are enritely within the target range, it's something else.
    If you want rows that entirely enclose the target range, it's something else again.

  • Findig dates between two dates

    Hi everybody,
    I have one table (TEST) with 2 columns having only one record
    i need list of dates between from_date and to_date
    the sample data...
    from_date to_date
    ====== ======
    02-JUL-09 17-JUL-2009
    I found below query to retrieve the dates between two dates.
    select to_date('02-jul-2009','dd-mon-yyyy')+level-1 dt from dual
    connect by level<=to_date('17-jul-2009','dd-mon-yyyy')-to_date('02-jul-2009','dd-mon-yyyy')+1
    It is working properly.
    i have changed the above query with my table column names
    select to_date(from_date,'dd-mon-yyyy')+level-1 dt from Test
    connect by level<=to_date(to_date,'dd-mon-yyyy')-to_date(from_date,'dd-mon-yyyy')+1
    In this case it is not working...
    i am unable to find the reason...
    Thank you.

    Hi,
    It is working fine for me, what is the data type for from_date and to_date.
    select to_date(from_date,'dd-mon-yyyy')+level-1 dt from Test
    connect by level<=to_date(to_date,'dd-mon-yyyy')-to_date(from_date,'dd-mon-yyyy')+1;
    DT
    02-JUL-09
    03-JUL-09
    04-JUL-09
    05-JUL-09
    06-JUL-09
    07-JUL-09
    08-JUL-09
    09-JUL-09
    10-JUL-09
    11-JUL-09
    12-JUL-09
    13-JUL-09
    14-JUL-09
    15-JUL-09
    16-JUL-09
    17-JUL-09Regards
    Anurag Tibrewal
    PS: Also post your output with the second query.

  • Bestway to find difference between two roles in quality and production

    We have a process of collecting su53 dump and then analyze for missing authorization . However some time although everything works fine in quality , it fails in production . Hence I want to know a simple methodology to compare roles in quality and production to know difference ... Can anyone share best methodolgy being used in your setup ?
    NPB

    (1)How to find the difference between two dates at Universe level and at report Level in IDT?
    DaysBetween ([Sale Date];[Invoice Date]) returns 2 if [Sale Date] is 15 December 2001 and [Invoice Date] is 17 December 2001.
    (2) How to change format of dates from YYYY/MM/DD to DD/MM/YYYY in IDT at prompt level ?
    =FormatDate(ToDate(YOUR DARE OBJECT);"YYYY/MM/DD");"dd'/'MM'/'yyyy")
    =To_Char (object name, required format)
    Find the below link for more info.
    http://scn.sap.com/community/semantic-layer/blog/2014/04/18/bi41-business-layer-enhancements--create-display-format
    (3)What is VIEWS in IDT of data foundation layer when we right click? could u plz give one example where exactly we use VIEWS?
    A custom data foundation view is a subset of the data foundation Master view. You can use views when editing a large data foundation, and interested in working with a subset of tables. You can define multiple custom views for the data foundation due to the complexity of the data warehouse.
    Essentially, need created views for each individual star scheme (like Sales, Production, Finance, Accounting, etc.) plus a view for eachcomplex dimension structure (like Business Partner, Material, Customer, Plant etc.),
    Find the below link for more info.
    http://scn.sap.com/docs/DOC-54422
    (4) How to represent & report my IDT data in dashboards? could u plz explain the steps?
    Please find the below link: http://scn.sap.com/docs/DOC-27559

  • Working days between two date fields and Changing Factory Calendar

    Hi,
    I have to calculate working days between two date fields excluding the weekends and public holidays for Switzerland.
    I have written the routine using factory calender and its working fine except for two problems now:
    1. If any one of the date field is empty then teh rsult should be zero.
    2. And the below code is working from 1996 but my cleints wants it to work for years before 1996 as well.
    I also tried to change the Start date in SCAL for factory calendar but it says enter values between 1995 to 2020.
    I am new to ABAP. Please help me how i can achieve these for below code.
    DATA: IT_HOLIDAYS type TABLE OF ISCAL_DAY,
          IS_HOLIDAYS TYPE ISCAL_DAY.
    DATA: T_DATE TYPE SY-DATUM,
          P_DATE TYPE SY-DATUM.
    DATA : X_DATE(4) TYPE C.
    DATA: CNT TYPE I.
    REFRESH : IT_HOLIDAYS.
    CLEAR : IT_HOLIDAYS.
    T_DATE = SOURCE_FIELDS-/BIC/ZCCCHP812.
    P_DATE = SOURCE_FIELDS-/BIC/ZCCCHP810.
    CALL FUNCTION 'HOLIDAY_GET'
    EXPORTING
    HOLIDAY_CALENDAR = 'CH'
    FACTORY_CALENDAR = 'CH'
    DATE_FROM = P_DATE
    DATE_TO   = T_DATE
    TABLES
    HOLIDAYS = IT_HOLIDAYS
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND = 1
    HOLIDAY_CALENDAR_NOT_FOUND = 2
    DATE_HAS_INVALID_FORMAT = 3
    DATE_INCONSISTENCY = 4
    OTHERS = 5.
    DESCRIBE TABLE IT_HOLIDAYS LINES CNT.
    X_DATE = T_DATE - P_DATE - CNT.
    RESULT = X_DATE.
    Please help
    Regards
    Zabina
    Edited by: Syed786 on Nov 2, 2011 9:15 AM

    Hi Zabina,
    Try this function module  'DURATION_DETERMINE'.
    Give the factory calendar and unit as DAY
    With regards,
    Rajesh

Maybe you are looking for

  • InvalidJadException

    Dear All, I'm facing problem with MIDlet. When I 'build' the program, there was no error. But, when I 'run' the program, the execution suddenly completed without any action from me. For your info, I have run the program twice (succesfully) before the

  • Data Type for HTTP

    Hey guys i have a HTTP to File scenario where in my getting and XML file which has sone tags of this form <ServiceDateTime dateTypeIndicator="PromisedForDelivery">2007-04-06</ServiceDateTime> how should i create data type for this? is this an attribu

  • Metapackage File Errors On Hybrid Cd In Mac OS 10.3

    I've a PackageMaker built Metapackage, Install.mpkg, burn into a Hybrid CD. Running Install.mpkg under OS 10.4 doesn't have problems, but when I run it under OS 10.3, there's always an error saying Install.mpkg couldn't be read. The file itself is wo

  • Intermittent slow network browsing

    Hi, We are experiencing a weird issue with network browsing from Windows 7 x64 enterprise edition on a Server 2008 R2 share. What happens is when a user browses a network share and selects a file, it takes +-20 seconds to select the file. If multiple

  • Reconnecting and Duplicates

    Is there a function in Starter Edition that one can "search for duplicates"? Or, how do I remove them from categories so they are all in a huge pool of images? If I take them out of categories, where do they go? Will they be deleted? I am trying to c