Differnce between two days

Hi All,
I want function module to get difference between two days. (billing date and delivery date).
So,can you help me out.
Regards,
Priya.

Hi
HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
Also go through the link given below :
http://www.saptechies.com/abap-function-modules/
With Regards
Nikunj shah

Similar Messages

  • How to find out public holiday between two days.

    Can any one let me know FM to find out public holiday between two days.
    for example: i am entering two days as 10-08-2009 to 20-08-2009. We have 15-08-2009 is a holiday. FM should say that 15th August is the public holiday.
    Regards,
    Manoj.

    hi,
    you can use HOLIDAY_CALENDAR_GET FM to get the holiday calendar id .
    Then pass that calender id and date to FM HOLIDAY_CHECK_AND_GET_INFO.
    Rgds.,
    subash

  • How to Calculate the Time Between two days in ABAP

    Hi,
                  I have one scenario like i need to calculate the time between two days please can you suggest me.
    Thanks,
    Harinath

    Hi Peeleti,
                Check this code,
    DATA : DATE1 LIKE SY-DATUM VALUE '19830125',
           DATE2 LIKE SY-DATUM VALUE '20070219',
           DAYS1 TYPE I,
           WEEK1 TYPE I,
           MONTH1 TYPE I,
           YEAR1 TYPE I,
           C_YEARS1 TYPE I.
    CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
    EXPORTING
      BEGDA           = DATE1
       endda           = DATE2
      TAB_MODE        = ' '
    IMPORTING
      DAYS            = DAYS1
      C_WEEKS         =
      C_MONTHS        = C_YEARS1
      C_YEARS         = C_YEARS1
      WEEKS           = WEEK1
      MONTHS          = MONTH1
      YEARS           = YEAR1.
      D_MONTHS        =
      MONTH_TAB       =
    *WRITE : / 'DAYS   = ', DAYS1,
            / 'WEEKS = ',WEEK1,
          /  'MONTHS = ', MONTH1,
          / 'YEARS   = ', YEAR1.
    Using this code you can calculate the No Of Days Between two dates. Based On days you will easily calculate the Hour. [  No of days * 24 ].
    Thanks.
    Reward If helpful.

  • Fucntion to Calculate business days (exclude weekends & holidays) between two days

    Hello,
    I need to be able to calculate business days between two dates excluding weekends and holidays. I do have a date dimension and also flags which denote weekday, holiday. Would really appreciate help in building a udf for the business days calculation.
    Thanks,

    Hi, Please take a look and tweak accordingly. Best of luck.
    --Assuming data dimension table something like the following
    --tblDateDim (DT date primary key,
    flagHoliday bit,
    flagWeekday bit
    CREATE FUNCTION fnBusinessDays (
    @StartDate DATE,
    @EndDate DATE
    RETURNS INT
    AS
    BEGIN
    DECLARE @Days INT ;
    SELECT @Days = count(*)
    FROM tblDateDim --// date dimension
    WHERE
    ( DT BETWEEN @StartDate AND @EndDate) --// dt is date column in the table.
    AND --// also flags which denote weekday, holiday
    flagHoliday = 0 --// flagHoliday= 1--Holiday;= 0 --workingday/businessday
    AND
    flagWeekday = 1 --// FlagWeekday = 1--businessday ; =0 --weekend (Saturday and Sunday)
    RETURN (@Days)
    END
    GO

  • Days between two days except weekend

    Hi all he lp me in getting a oracle query to find out the days between 2 input dates excluding the weekends...

    >
    Hi all he lp me in getting a oracle query to find out the days between 2 input dates excluding the weekends...
    >
    Something like this should work
    with dates as (select sysdate fromDate, sysdate + 10 toDate from dual),
      days as (select sysdate + level - 0 myDay from dates
               connect by level < toDate - fromDate)
    select count(*) from days where to_char(myDay, 'Dy') not in ('Sat', 'Sun')
    COUNT(*)
    6The 'dates' query just provides the start and end dates. The 'days' query produces a date value for each day in the range between the start and end.
    Then the last query counts those days if they are not a Saturday or Sunday.
    You can adjust the 'days' query depending on whether you want both the start and end date included. For example if start is today and end is tomorrow (Friday) the above query result will be '1'.
    Are you forgetting to mark your questions ANSWERED when they have been? Total Questions: 12 (10 unresolved)

  • How to fetch values between two days of a month

    Hi,
    I have fetch the values which are greater inserted on or after of 16th day of one and any month.
    I am trying with following query for a month of dec :
    select *
    from tablename
    where SUBSTR(TO_DATE(TO_CHAR(colname, 'DD-MON'),'DDMM'),1,6) >= '16-Dec'
    and SUBSTR(TO_DATE(TO_CHAR(colname, 'DD-MON'),'DDMM'),1,6) < '31-Dec'
    but its not giving me the desired result.
    I have to pick the resultset of everyyear.
    Please help me in this matter.

    Thanks a lot guys!!
    My problem is solved.That's good news, but be aware that the solutions presented are not all good:
    SQL> select * from tablename order by colname
      2  /
    COLNAME
    23-12-2005 11:03:12
    28-12-2005 11:03:12
    02-01-2006 11:03:12
    13-11-2006 11:03:12
    13-12-2006 11:03:12
    23-12-2006 11:03:12
    24-12-2006 11:03:12
    25-12-2006 11:03:12
    31-12-2006 11:03:12
    9 rijen zijn geselecteerd.
    SQL> select colname
      2    from tablename
      3   where to_date(to_char(colname,'ddmm') || '2006','ddmmyyyy')
      4         between to_date('16122006','ddmmyyyy')
      5             and to_date('01012007','ddmmyyyy') - 1/24/60/60
      6  /
    COLNAME
    23-12-2006 11:03:12
    24-12-2006 11:03:12
    25-12-2006 11:03:12
    31-12-2006 11:03:12
    23-12-2005 11:03:12
    28-12-2005 11:03:12
    6 rijen zijn geselecteerd.
    SQL> remark Mohana's solution
    SQL> select *
      2  from tablename
      3  where TO_CHAR(colname, 'DD-MON') >= '16-DEC'
      4  and TO_CHAR(colname, 'DD-MON') < '31-DEC'
      5  /
    COLNAME
    23-12-2006 11:03:12
    24-12-2006 11:03:12
    25-12-2006 11:03:12
    23-12-2005 11:03:12
    28-12-2005 11:03:12
    5 rijen zijn geselecteerd.
    SQL> remark user503699's solution
    SQL> select *
      2  from tablename
      3  where TO_CHAR(colname, 'MON') = 'DEC'
      4  and ( TO_NUMBER(TO_CHAR(colname, 'DD')) >= 16
      5  and TO_NUMBER(TO_CHAR(colname, 'DD')) <= 31 )
      6  /
    COLNAME
    23-12-2006 11:03:12
    24-12-2006 11:03:12
    25-12-2006 11:03:12
    31-12-2006 11:03:12
    23-12-2005 11:03:12
    28-12-2005 11:03:12
    6 rijen zijn geselecteerd.
    SQL> remark Rup's solution
    SQL> select *
      2  from tablename
      3  where TO_CHAR(colname, 'DD-MON-yyyy') >= to_date('16-DEC','dd-mon')
      4  and TO_CHAR(colname, 'DD-MON-yyyy') < to_date('31-DEC','dd-MON')
      5  /
    COLNAME
    23-12-2006 11:03:12
    24-12-2006 11:03:12
    25-12-2006 11:03:12
    3 rijen zijn geselecteerd.So use user503699's solution or mine ;-)
    Hope this helps.
    Regards,
    Rob.

  • Differnce between  two types  of declaration

    Hi all,
    TYPE number_x_x is table of number;
    number_x number_x_x;
    TYPE number_y_y is table of number index by binary_integer;
    number_y number_y_y;
    Can i know what is the difference between these two, and in what scenario's can i use each of them.
    Thanks

    There's a useful chart at SQL Snippets: PL/SQL Collections - Choosing the Right Collection Type which highlights the differences between nested tables and associative arrays and can help you decide which one is best for your needs. There's also some sample code for both types of collections in other pages under the "PL/SQL Collections" section.
    HTH.
    Joe Fuda
    SQL Snippets

  • Count Date Range Between two day.

    jdk now have a Calendar class.
    Import the class And
    Calendar.DAY_OF_YEAR;

    Huh?
    Do you have a question or do you always post random gibberish on the net?

  • How to calculate the no. of weekdays between two active dates

    Hi all,
    I need to calculate the no. of weekdays between two days.
    For Example:
    If i want to know the number of weekdays between 17-NOV-2008 to 7-DEC-2008 its 10 excluding sat and sun.
    how to do that if the period is more?
    like 1-JAN-2006 to 12-APR-2007
    Thanks in advance..
    Regards,
    Manoj

    NEXT_DAY(start_date - 1,'SUNDAY') is first sunday >= start_date. NEXT_DAY(end_date - 7,'SUNDAY') is last Sunday <= end_date. Therefore:
    (NEXT_DAY(end_date - 7,'SUNDAY') - NEXT_DAY(start_date - 1,'SUNDAY')) / 7 + 1 is number of Sunday's between start_date and end_date. Same way:
    (NEXT_DAY(end_date - 7,'SATURDAY') - NEXT_DAY(start_date - 1,'SATURDAY')) / 7 + 1 As a result, number of weekdays between start_date and end_date is:
    business_day_count := end_date - start_date + 1 -((NEXT_DAY(end_date - 7,'SUNDAY') - NEXT_DAY(start_date - 1,'SUNDAY')) / 7 + 1 + (NEXT_DAY(end_date - 7,'SATURDAY') - NEXT_DAY(start_date - 1,'SATURDAY')) / 7 + 1) or
    business_day_count := end_date - start_date - 1 -(NEXT_DAY(end_date - 7,'SUNDAY') - NEXT_DAY(start_date - 1,'SUNDAY')) / 7 - (NEXT_DAY(end_date - 7,'SATURDAY') - NEXT_DAY(start_date - 1,'SATURDAY')) / 7 or:
    SELECT end_date - start_date - 1 -(NEXT_DAY(end_date - 7,'SUNDAY') - NEXT_DAY(start_date - 1,'SUNDAY')) / 7 - (NEXT_DAY(end_date - 7,'SATURDAY') - NEXT_DAY(start_date - 1,'SATURDAY')) / 7 FROM DUAL; The above code assumes business day count between two dates includes both start and end dates. Keep in mind, the above code is NLS dependent.
    SY.

  • 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

  • Using pl/sql function for each day between two dates.

    Hi,
    create TABLE EMP(
    ID_EMP NUMBER,
    DT_FROM DATE,
    DT_TO DATE,
    CREATE_DATE DATE);
    into EMP(ID_EMP, DT_FROM, DT_TO, CREATE_DATE)
    Values(100, TO_DATE('07/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),TO_DATE('05/08/2009 14:11:21', 'MM/DD/YYYY HH24:MI:SS'));
    I have a function called  elig_pay_dates(date p_date), which returns the code for  person payment eligibility for a particular date. For paid dates it's 'P' and for unpaid dates it's 'N'.
    How can I check this function between two dates for each day. Example : 07/01/2008 to 04/30/2010.
    By using this function with select I needs to display the dates when there is a change in status.
    I am expecting data in following manner from above logic(this is example):
    07/01/2008 --- 07/01/2009 ---'P'
    07/02/2009 -- 07/25/2009 ----'N'
    07/26/2009 -- 01/01/2010 ---'P'
    01/02/2010 -- 01/13/2010 --'N'
    01/14/2010 -- 01/18/2010 --'P'
    01/19/2010 -- 04/30/2010 -- 'N'
    I thought of looping for each day date but that seems to be expensive for online application. Is there any way that I can achieve this requirement with sql query ?
    Thanks for your help,

    Certainly not the best way to code the requirement, but it does achieve the result you are looking for in a fairly quick time
    create or replace
    function test_ret_paid_unpaid (p_date in date)
    return varchar2
    is
      v_ret     varchar2(1);
    begin
      if ( (p_date between to_date('07/02/2009', 'MM/DD/YYYY') and to_date('07/25/2009', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/02/2010', 'MM/DD/YYYY') and to_date('01/13/2010', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/19/2010', 'MM/DD/YYYY') and to_date('04/30/2010', 'MM/DD/YYYY') )
        then v_ret := 'N';
      else
        v_ret := 'Y';
      end if;
      return v_ret;
    end;
    Wrote file afiedt.buf
      1  with get_paid_unpaid as
      2  (
      3    select dt_from start_date, dt_to end_date, dt_from + level - 1 curr_date, test_ret_paid_unpaid(dt_from + level - 1) paid_unpaid,
      4           row_number() over (order by dt_from + level - 1) rn_start,
      5           row_number() over (order by dt_from + level - 1 desc) rn_end
      6      from test_emp
      7    connect by level <= dt_to - dt_from + 1
      8  ),
      9  get_stop_date as
    10  (
    11  select start_date init_date, end_date, curr_date, paid_unpaid,
    12         case when paid_unpaid != lag(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    13          then curr_date
    14          else null
    15         end start_date,
    16         case when paid_unpaid != lead(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    17          then curr_date
    18          else null
    19         end stop_date
    20    from get_paid_unpaid
    21  )
    22  select period, paid_unpaid
    23    from (
    24  select init_date, curr_date, start_date, end_date, stop_date,
    25         case when paid_unpaid = lead(paid_unpaid) over (order by curr_date)
    26                then nvl(start_date, init_date) || ' - ' || lead(stop_date, 1, end_date) over (order by curr_date)
    27              else null
    28         end period,
    29         paid_unpaid
    30    from get_stop_date
    31   where stop_date is not null or start_date is not null
    32         )
    33*  where period is not null
    12:06:10 SQL> /
    PERIOD                                             PAID_UNPAID
    01-JUL-08 - 01-JUL-09                              Y
    02-JUL-09 - 25-JUL-09                              N
    26-JUL-09 - 01-JAN-10                              Y
    02-JAN-10 - 13-JAN-10                              N
    14-JAN-10 - 18-JAN-10                              Y
    19-JAN-10 - 30-APR-10                              N
    6 rows selected.
    Elapsed: 00:00:00.35

  • Calculate Difference in Days Between two Dates

    Hi,
    I'm trying to figure out how to calculate the difference in days between two dates using JavaScript in LiveCycle. (JavaScript knowledge = minimal)
    Where "Start_Date" and "Current_Date" are the names of the two dates in the Hierarchy palette. (both Date/Time Field)
    *Current date is using the Object > Value > Runtime Property > Current Date/Time
    I need a Text or Numeric field displaying the difference in days. (Difference_in_Days)
    I've noticed the following code being pretty standard amongst other responses:
    var 
    Start_Date = new Date(Start_Date);
    var 
    Current_Date = new Date(Current_Date);
    var 
    nAgeMilliseconds = Current_Date.getTime() - Start_Date.getTime();
    var 
    nMilliSecondsPerYear = 365 * 24 * 60 * 60 * 1000;
    I know there's code missing, and the above code might not be correct.
    Please advise.

    Where "DateField01" = user entered date field
    Where "DateFiled02" = Current Date/Time (Runtime Property)
    where "Subform" = the subform containing DateField01
    My script now resembles:
    var oneDay = 24*60*60*1000;
    var firstDate = new Date(Subform.DateField01.rawValue);
    var secondDate = new Date(DateField02.rawValue);  
    (firstDate.getTime() - secondDate.getTime()) / oneDay;
    I tried adding:
    app.alert(String(diffDays));
    Although I assume the reason I didn't get an error is because DateField01 is empty when the form is opened.
    If I swap in actual dates instead of fields it works perfectly.
    When I use the fields I have no information populating after I enter a date in "DateField01"

  • How can I calculate the maximum number of days between two dates in a range of dates?

    I have a column of dates spanning the couse of a few months.  I would like to know if I can calculate the maximum number of days between each row and display the highest number.  I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
    Is this possible?  Any help or suggestions are appreciated.
    Thank you,
    Trevor

    This sounds totally possible,  Can you post a screen shot of your table to make responding more focused?  If you mean you want to:
    A) compute the difference (in days) between two date in the same row, then
    B) find the max duration (in days)
    Here is my take on this problem:
    D2 = C2-B2
    select D2 and fill down
    F1=MAX(D)
    to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image

  • How to calculate number of days between two date in Template design?

    Hello guys
    I have a situation where I have to create a template that returns data, and one of the thing of the existing report is that there is a column that is actually the number of days between start date and end date columns..
    So in template, how would I be able to do the same? I have start date and end date columns on the template, now when I created another column using expression like end date - start date and preview the template, I am getting errors saying :
    Caused by: oracle.xdo.parser.v2.XPathException: Cannot convert 03/31/2009 to number.
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
    Please advice
    Thanks

    Hi
    There is an extension function you can use, from the javadoc:
    date_diff
    public static long date_diff(java.lang.String format,
    java.lang.String fromDate,
    java.lang.String toDate,
    java.lang.String locStr,
    java.lang.String tzID)
    Method to get the difference between two dates in the given locale. The dates need to be in "yyyy-MM-dd" format. This function supports only Gregorian calendar.
    Parameters:
    format - the format to which the difference is required; allowed formats are y (for Year), m(for month), w(for week), d(for day), h(for hour), mi(for minute), s(for seconds) and ms(for milliseconds)
    fromDate - the first date
    toDate - the second date
    locStr - locale string -> lang-Territory
    tzID - timezone ID ->http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html
    Returns:
    the difference in dates in the desired format
    For example
    <?xdoxslt:date_diff(‘d’,’2009-09-14’, ‘2009-09-20’,’en-US’,1)?>
    give a result of 6
    You can substitute in columns for the dates, just remember the date format required.
    Regards
    Tim

  • I wanted to know how do you calculate the number of days between two dates

    i wanted to know how do you calculate the number of days between two dates in java ? i get both the dates from the database. i guess there are many issues like leap year and Febuary having diff no of months ..etc.

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

Maybe you are looking for

  • How can I upgrade from iPhoto 6 using SnoLeopard?

    I'm trying to create a slideshow for my aunts memorial service and I am realizing that my iPhoto 6 (v. 6.0.6) is severely out of date. I'm using OS X 10.6.8 I tried going to upgrade to iPhoto 11 but when I do, it's saying that I need OS X 10.7.4 in o

  • Account posting at billing

    Hello Folks, Am I right to say that Profit centre accounting document is posted when billing doc is posted in addition to FI accounting docs and CO-PA docs? Or is Profit center accounting doc classified as CO-PA docs? I know that FI accounting docs a

  • Condition Type the purchase order

    Hi Guru: Can anyone tell me that which table/transaction to include all the condition type of purchase order? Thanks.

  • How to set from field in template

    Hi all, We are using templates that always should be SentOnBehalfOf but as you can imagine it is often forgotten to change the from field ... Is there a way to set the from field to a pre-defined value? I don't get it done. Thanks for any suggestion.

  • DIP - Sales Price -Resource related biling

    Hi All Please refer discussion - Sales Price -Resource related biling My case is more or less same as above discussion. I completely understood the DIP settings you mentioned, as far as my case is concern, this is purely a service company where they