How to count the days between Date Range using OO ABAP?

hi experts,
        i want to count the days between Date Range using OO ABAP for that  which class and method  can i use?.
Thanks,
Mahesh.

Not sure I understand the requirement for it to be OO, but you could always write your own (i.e. use this):
REPORT zz_date_diff.
CLASS date_diff DEFINITION.
  PUBLIC SECTION.
    METHODS diff IMPORTING     i_date_fm TYPE d
                               i_date_to TYPE d
                 EXPORTING     e_days    TYPE i.
ENDCLASS."
CLASS date_diff IMPLEMENTATION.
  METHOD diff.
    e_days = i_date_to - i_date_fm.
  ENDMETHOD."
ENDCLASS."
DATA: g_ref TYPE REF TO date_diff,
      g_days  TYPE i,
      g_date_fm  TYPE d VALUE '20080101',
      g_date_to  TYPE d VALUE '20090101'.
START-OF-SELECTION.
  CREATE OBJECT g_ref.
  CALL METHOD g_ref->diff
    EXPORTING
      i_date_fm = g_date_fm
      i_date_to = g_date_to
    IMPORTING
      e_days    = g_days.
  WRITE g_days.

Similar Messages

  • How to reduce the number of data blocks used by table

    Hi,
    I was trying to reduce the space usage of a particular table of my apex application which stores blob content and therefore deleted many records from it.
    However, the data block usage remained the same as before.
    I have tried to 'analyze' the table and validate the structure,but am unable to overcome this problem.
    Could someone throw some light on what needs to be to reduce the number of data blocks used by this table?
    Best Regards,
    Priya Jetley

    Priya:
    It is likely that the BLOB content defined in your table is being stored 'Out-of-Line'. This means that the LOB columns are stored in segments of their own. These then are the segments that may need shrinking.
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14249/adlob_tables.htm#i1006363
    Varad

  • How to calculate the days between last movement of material till today date

    Hello Experts,
    Could someone help me please?
    I have a key figure in the InfoCube 0IC_C03 witch contain the last date of movement of material.
    (it is a key figure created in format date and contain the max value).
    How can I to calculate the number of days between this date (last movement),  till today date (system date).
    I need to show:
    material........last movement.....days without movements.
    xxxxxxxxxxx.....dd/mm/yyyy..........9999
    Im trying to do this calculation in bex using variable formula but it doesn't work becouse current date (customer exit) brings sy-datum in format yyyymmdd and the kf-last-mov is in format number (I dont know what kind of number)
    Thanks in advance,
    Points are assured.
    Regards,
    Silvio Meurer.
    Message was edited by:
            Silvio Meurer

    Hi Parth,
    Here we are using the version 7.0 and SP 10, I'm afraid I could not understand you. I Can't find the function DATE_DIFF (Where is it?)
    I'm using the formula and it doesn't work. Coud you see the result is:
    last movement date     Today date        result
    02.04.2007                  20.070.625       19.337.856
    18.05.2007                  20.070.625       19.337.810
    the "today date" is from customer exit and the result is a strange number to me.
    Could you help me?

  • Need JavaScript for Sharepoint Designer 2010, to show a Pop-up to all the users between date range and the redirect the site

    Dear all,
    I am very new to Sharepoint designer 2010. Its better to say, i am just stepping in.
    I have sharepoint site which is accessible for all the users to update few information. But i want this site not to be accessible during a date range, say from 15th to 20th of every month.
    I am planning to have something like this: If any user tries to access this sharepoint site between 15th to 20th date range of everymonth, then the browser must show an pop-up alert saying "This site is not accessible during this date range" and Redirect
    this sharepoint site to someother site (Say http:// somesitename.xx.com) immidiately.
    I know very little about how to add Javascript in sharepoint webpart.
    Please provide the Javascript or any best alternate solution to my concern.
    Thanks in advance.

    Hi,
    From your description, my understanding is that you want to redirect sharepoint site to another site between 15th and 20th every month.
    I agree with what Sudip says. If you still want to use JS code,You could try these steps
    below:
    Open your site with SharePoint Designer.
    Click Master Pages in left navigation.
    Find file v4.master, and backup it(it is very important).
    Right click your v4.master,
    choose "Edit File in Adavance Mode".
    Add the code below into the <head/> tag.
    <script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script><script
    type="text/javascript">
    $(document).ready(function(){
    var today = new Date();  
    var day = today.getDate(); // get current day
    var id = _spPageContextInfo.userid; // get the id of current logon in user
    var boolFlg = false;
    $.ajax({
       url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteGroups/GetByName(\'"+"sharepoint Owners"+"\')/Users", //get users in a specified group can access the sharepoint site from 15th to 20th every
    month
       type: "GET",
       headers: {"accept": "application/json;odata=verbose"},
       success: function (data) {
          if (data.d.results) { 
             var src = data.d.results;
             for(var i = 0; i < src.length; i++){
                if(src[i].userid==id){ //check the logon in user in  the specified group or not
                   boolFlg = false;
                   break;
             if(!boolFlg){
                if(day <= 20 && day >=15){
                    alert("This site is not accessible during this date range"); // alert the message
                    location.href = "http:// somesitename.xx.com"; // redirect to another site
       error: function (xhr) {
          alert(xhr.status + ': ' + xhr.statusText);
    })</script>
    Best Regards
    Vincent Han
    TechNet Community Support

  • Ms project 2010 - grouping how to show the duration between dates at the summary level

    Hi we have a ms project plan where we have used grouping to present the task breakdown in a different structure.
    This works great we get at the summary level the start and finish dates correctly but the duration gives us only the Maximum value for the durations of the tasks within the group. (is it possible to change the maximum calculation?)
    We would like to be able to determine the duration at the summary level. Of note if we use functions such as projdatediff(start,finish) this only gives the result at the detail level and does not show at the summary level - even if we check the do the
    calculation for the task and group levels 'use formula' radio button.
    is this a bug???.
    If we use a numeric calculation such as finish-start we get a figure that allows  us to repeat the calculation at the group (summary) level. but firstly we do not actualy know what the numeric value represents. i.e (Finish-Start)*10000 for
    a duration of 0.5 hours = 208.33 ,1 hr= 416.67,1.5 hrs =625, but 8 hrs is giving 10833.33 which is 24 * the 1 hour figure
    duration  finish-start  start           finish
    0.5hrs     208.33    Tue 31/01/12 Tue 31/01/12
    1d          10833.33 Tue 31/01/12 Wed 01/02/12
    8 hrs      10833.33 Tue 31/01/12 Wed 01/02/12
    0.19d     625          Wed 01/02/12 Wed 01/02/12
    1.5 hrs   625          Wed 01/02/12 Wed 01/02/12
    0.13d     416.67     Wed 01/02/12 Wed 01/02/12
    1 hr        416.67     Wed 01/02/12 Wed 01/02/12
    Anyhow looking for suggestions on how to get a calculation of the difference in two dates as units (pref days) into the group level summary.
    Many thanks Mike

      Hi John ,
    This is better ..... Now the Text1  column is the correct duration .. Is it possible just to display the Text 1 Column instead of Duration Column ? is it a right practice in using Microsoft Project or scheduling ? This is an alternate solution
    ...Do you think that there is a solution to  that problem ?
    Task Name
    Text1
    Duration
    % Complete
    Start
    Finish
    F10E ( Level 10 )
    273
    40d
    0%
    10 Apr '12
    10 May '13
    Hospital Admin
    40
    40d
    0%
    10 Apr '12
    05 Jun '12
    Hospital Move- Vacate F10E
    40
    40 d
    0%
    10 Apr '12
    05 Jun '12
    Eastern/Kelson
    238
    40d
    0%
    30 May '12
    10 May '13
    Investigate Above Ceiling Conditions
    20
    20 d
    0%
    30 May '12
    26 Jun '12
    Hoardings
    5
    5 d
    0%
    06 Jun '12
    12 Jun '12
    Demolition (All)
    20
    20 d
    0%
    20 Jun '12
    18 Jul '12
    HVAC- main duct Work, Fire dampers
    40
    40 d
    0%
    19 Jul '12
    14 Sep '12
    Layout Partitions
    5
    5 d
    0%
    19 Jul '12
    25 Jul '12
    Steel stud Framing & Hollow Metal Frames
    30
    30 d
    0%
    17 Sep '12
    29 Oct '12
    Ceiling and Bulk Head Framing
    10
    10 d
    0%
    30 Oct '12
    12 Nov '12
    Mechanical Rough-In to Ceiling
    25
    25 d
    0%
    13 Nov '12
    17 Dec '12
    Taping,Drying & Sanding
    20
    20 d
    0%
    04 Dec '12
    03 Jan '13
    Ceiling and Bulk Head Drywall
    10
    10 d
    0%
    04 Dec '12
    17 Dec '12
    Painting
    15
    15 d
    0%
    04 Jan '13
    24 Jan '13
    T-Bar and Acoustic Ceiling Tile With Devices
    11
    11 d
    0%
    22 Jan '13
    05 Feb '13
    Head Walls system
    7
    7 d
    0%
    25 Jan '13
    04 Feb '13
    P-Lam Corridor Canopy Ceiling
    15
    15 d
    0%
    25 Jan '13
    14 Feb '13
    P-Lam Corridor and Room Canopy Ceiling
    10
    10 d
    0%
    25 Jan '13
    07 Feb '13
    Steel Doors, Wood Doors, Hardware
    15
    15 d
    0%
    08 Mar '13
    28 Mar '13

  • How to Get the difference between date

    Hi
    I try this query to find the difference between 2 date given in the below query.
    But the query can't be execute..
    Please try this query and give the correct one...
    select to_date(to_char(LAST_DAY('2005/03/15')+1,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date('2003/06/15','yyyy/mm/dd') No_days from dual
    Thanks

    try this
    SELECT last_day(to_date('2005/03/15', 'yyyy/mm/dd') + 1) -
    to_date('2003/06/15', 'yyyy/mm/dd') no_days
    FROM dual
    LAST_DAY return a date not a varchar

  • How to find the value of date char used as exception aggregation reference

    Hi BI Gurus,
    On a BEx report I need to list three things by material:
    1)   the open (not yet delivered) Purchase Order quantities
    2)   the PO quantity to be delivered next and
    3)   the date that belongs to the next delivery
    The model supports these data i.e. for each material I can list all open quantities by Purchase Order / Item / Schedule line and the scheduled delivery dates are also available as a characteristic.
    Determining 1) is easy – as the drilldown is fixed (materials only) the open quantities get summarized for all PO-s belonging to the materials.
    To determine 2) I used a Calculated KF simply including KF 1) “=Open PO Qty” in the definition and setting Exception Aggregation (first value) with a reference char of the delivery date. This gives back the Open PO Quantity to be delivered first.
    My question is about how to determine the 3rd value (actually this is not a KPI but a characteristic value). In other words, for each materials I would need to determine the first among all of the possible delivery date char values of the open PO Items / schedule lines. This is the date the quantity shown in the 2nd KPI will be delivered on.
    Does anybody have an idea how to approach this issue?
    Thanks for you help in advance,
    Attila

    Hi Olivier,
    Thanks for your suggestion. I got a bit closer with the replacement path formula variable and the CKF. I tried to apply the same logic of KPI 2) but for some reason it did not work. Actually, it delivers the right value but only when 0SCL_DELDAT (Scheduled delivery date) is in the drilldown… But what I need is the first delivery date by Material only, and without this 0SCL_DELDAT drilldown.
    Any other ideas?
    Thanks and bye,
    Attila

  • How to get the list of data providers used in a web template?

    I want to find a quick way to retrieve the list of data providers defined in the <object> tag in the Web template. One awkward approach is to parse the entire HTML page for <object> then filter out "DATA_PROVIDER: xxx".
    But is there any method or function call to retrieve the list quickly?
    Thanks!

    Try the function below, pass the item name and get the Data provider for that particular item, you will have to do this for all the items in the template.
    function getDPName(item){
         prop = SAPBWGetItemProp(item);
         var tableHidden=true;
         if (prop != null){
           for(i=1;i<prop.length;i++){
             if (prop<i>[0] == "DATA_PROVIDER")
                   return prop<i>[1]
           }//end for
         }//end if
    }//end function
    Thanks.

  • How to configure the connection between AS JAVA and AS ABAP

    Hello,
    I have installed a SAP Netweaver 7.3 AS JAVA and I would like to connect this JAVA Instance with 3 ABAP Systems (ECC 6.0) .
    On help.sap.com I have found the following instructions: http://help.sap.com/saphelp_nwpi71/helpdata/en/3b/0c4b428f96ab53e10000000a1550b0/content.htm
    Could you please advise, if the above configuration steps are OK?
    Or could you please help me with the exact procedure?
    Thank you in advance!
    Noemi

    Noemi,
    I'm not sure how exactly you want to use ABAP and Java so it is hard to answer your question.
    The link that you posted describes the steps to configure ABAP as a Security Assertion Markup Language (SAML) service provider. As a service provider, the AS ABAP enables you to off-load the authentication of users onto an identity provider. The identity provider enables you to federate identities across domains for Single Sign-On (SSO).
    Check the following wiki page for a good overview of all the ways that you could connect to ABAP
    http://wiki.sdn.sap.com/wiki/display/ABAPConn/ABAPConnectivityHome
    Regards,
    Ventsi Tsachev

  • Count the no.of rows without using count function

    Hi,
    How to count the no.of rows without using the count function?
    Thanks,

    they won't be 100% accurate. You're correct, Bluefrog, but the same goes for doing a count(*) (depending on the size of the table, ofcourse):
    the table being queried might be under DML (deletes/inserts), and the next count(*) might give different results.
    Both approaches will never be 100% accurate.
    But simply selecting num_rows will be much much faster than doing a count(*).
    Counting the number of rows always reminds me of this ongoing discussion, by the way:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:127412348064#14136093079164 ;)
    Usually knowing the number of records by approximatly is sufficient, imo. 1000000 or 1000007 records: I don't care, don't need to know that.
    I've never needed to know the exact number of records in a table in my code, or been given a requirement that forced me to.

  • How to get the diff between two dates  -  # of days

    Hi Experts,
    I have requirement to know the difference between dates. In my presentation layer two columns as created date and updated date. I want to know the difference in # of days in the presentation services.
    Please provide some pointers.
    Thanks in adv
    svr

    Hi,
    In the presentation layer you can create a column with a custom formula of this:
    TIMESTAMPDIFF(SQL_TSI_DAY, datecolumn1,datecolumn2)
    The result shown in the column will be the difference in days between the two dates.
    Regards,
    Matt

  • How to change the year in a range of column dates to the new year?

    How to change the year in a range of column dates to the new year?

    Depends on the pattern of the dates. The last procedure will work for any pattern, or no pattern at all.
    For examples.the dates are assumed to be in column A, starting at A2
    Sequential dates?
    Enter first updated date in the first cell.
    Enter =A2+1 in cell A3. Copy the cell.
    Select A3 to the end of the list. Paste.
    With the cells still selected, Copy, then go Edit > Paste Values.
    Evenly spaced dates?
    Same procedure as above, but replace +1 in the formula with + and the number of days between dates in the list.
    Randomly spaced dates?
    Select cell B2. Press option-left arrow to insert a (temporary) column to the left of column B.
    Click on the empty cell B2 in the new column. Enter the formula below:
    =DATE(YEAR(A)+1,MONTH(A),DAY(A))
    Copy the cell, then select B2 - Bn where n is the last ow containing a date to be converted. Paste,
    With the cells still selected, Copy.
    Click on A2, then go Edit > Paste values.
    Click on the column B reference tab to select all of column B.
    Hover the mouse over the right end of the reference tab, and click the black triangle when it appears.
    Choose Delete Column from the menu that appears.
    Regards,
    Barry

  • Given various date ranges, count the occurrences of dates in PL/SQL

    i have a table of employees that have a start date and end date on a project. Some employees end date is null because they are still working on the project. So I want to find for each day in JAN, how many people on working on the project.
    So I generate the dates JAN 1 - 31 with this:
    Declare
      days DATE := To_Date('01-JAN-11','dd-mon-yy');
    BEGIN
      FOR days IN 1..31
      LOOP
        Dbms_Output.Put_Line(TO_CHAR(days ,'dd-Mon-yy'));
        days  := days  + 1;
      END LOOP;
    END; For employee X (ID 123), his start date is 1st and end date is 4th. So I use this query to list the dates he worked on (Jan1 jan2 jan3 jan4):
    DECLARE
    da Number;
    days Date;     
    sta emp.start%Type;
    BEGIN
    Select end-start+1
    Into da
    From emp
    where emp_id = 123;
    Select start
    Into sta
    From emp
    Where emp_id = 123;
      days  := To_Date(sta,'dd-mon-yy');
    FOR i IN 1..da
      LOOP
        Dbms_Output.Put_Line(TO_CHAR(days ,'dd-Mon-yy'));
        days  := days  + 1;
      END LOOP;
    END;Now the problem I am having is trying to do a for loop to check the work days from each employee in the table. I guess I need to iterate over the employee IDs. The above code, I entered the empoyee ID myself to find his work days, but I am trying to loop over all the employees to find and count the days. Any help on this part?
    Ultimately I am trying to get this:
    Day Count
    Jan 1 5
    Jan 2 3
    Jan 3 1
    Jan 31 5

    select  project_id,
            dt,
            nvl(count(emp_id),0)
      from  employee_projects,
            (select date '2010-12-31' + level dt from dual connect by date '2010-12-31' + level <= date '2011-01-31')
      where dt between start_date(+) and nvl(end_date(+),sysdate)
      group by project_id,
               dt
    /SY.
    Edited by: Solomon Yakobson on Jan 18, 2011 5:01 PM

  • How to make the exchange of data between 2 while loop in real time

    hello
    I have 2 while loop
    the 1st while loop includes the data acquisition program
    the 2nd while loop includes the control program
    my question is how to make the exchange of data between 2 while loop in real time
    I tried with the local variable and direct wiring between the 2 while loop
    it does not work (there is a delay)
    Solved!
    Go to Solution.

    Bilalus,
    Queues are only good to transfer data if your application isn't deterministic. Since you are using Real Time, I am assuming that your application requires determinism. If you are using Timed Loops and you use queues to transfer data between your loops, you are losing determinism. In this case, you need to use the RT FIFO functions. 
    Warm Regards,
    William Fernandez
    Applications Engineering
    National Instruments

  • How to get the day of 52 weeks ago data

    hi all:
    i recently encounter the difficulty that using the current data to get the 52 weeks ago data in essbase.the fct table is like this:
    current_dt the_day_of_week sales
    20110203 5dw05 100
    20100207 5dw05 30
    note: "5dw05" means the fifth day of five week in the selected year
    the question is which essbase formula to choise or how to use them in essbase outline structure can meet the bussines role that when the biz men chlic on the member "20110203" of time dimension, the extension mesure "bf_sales" value is 30.
    the outline i am about to design under the bellow:
    dim_time
    201002
    20110201(alias 4dw05)
    20110202(alias 5dw05)
    20110203(alias 6dw05)
    201102
    20110206(alias 4dw05)
    20110207(alias 5dw05)
    dim_measure
    sales
    bf_sales(will use the essbase formula,but do not know which function to choise or how to use it)
    i am lovely hope one of you may give me suggestion on this issue. thanks a lot for all of you!

    If you put the Apple calendar app on the first screen, it shows the day and date (no month/year). E.g Sunday 20.

Maybe you are looking for