Getting number of days between 2 dates

Hello All,
I require the number of days between 2 dates.
The number of days is between low date : PR Date (not an input variable) and the high date.
I have created an customer exit variable to get sy-datum in made it as formula variable.
I have also created a formula variable for PR Date , and subtracted the 2 dates.
It is not giving the correct result.
Any suggestions.
Thanks & Regards,
VL

Read through this web link.  It will show you how to calculate the days between 2 dates directly in your BEX query.
No exit needed to calculate this.
http://teklink.co.uk/sap/sap-bi-bw-how-to-use-replacement-path-variables-to-perform-date-calculations-in-the-bex-analyzer/

Similar Messages

  • How do i get number of days between 2 dates?

    How do i get number of days between 2 dates?
    and the result must be in int.
    for example
    Ex. startdate: 2006-06-01 enddate: 2006-06-30 and the result is: 30
    how to do so? thx

    mel
    Iv'e used this method. It assumes startdate,enddate and days have been defined before but you could pass them as args.
    void days()
        try
          Date d1 = DateFormat.getDateInstance().parse(startdate);
          Date d2 = DateFormat.getDateInstance().parse(enddate);
          long days = (d2.getTime()-d1.getTime())/1000/60/60/24;
          days = ""+days;
        catch (ParseException e)
          System.out.println("Invalid date format");
      }It actually gets the duration in ms and divides down to days.
    Regards
    Chris

  • How  can I get number of days between 2 dates ?

    How can I get number of days between 2 dates ?
    Give me answer as soon as possible.....

    Mukesh_Prajapat wrote:
    How can I get number of days between 2 dates ?
    Give me answer as soon as possible.....Is google broken again?
    [How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html]

  • How can i get number of days between two dates represented by two dates?

    how can i get number of days between two dates represented by two date objects. One is java.sql.Date, the other is java.util.Date?

    tej_222 wrote:
    But how do I do that conversion. from java.sql.date and java.util.date to calender?
    -thanks for the quick response.You may find the following utility code samples useful:
    [http://balusc.blogspot.com/2007/09/calendarutil.html]
    [http://balusc.blogspot.com/2007/09/dateutil.html]
    ganeshmb wrote:
    (date1.getTime() - date2.getTime())/(1000*60*60*24) should do.
    getTime returns millsecond value of date object and the difference divided by no of milliseconds in a day should fetch you the difference in terms of days.This doesn't respect the DST. Use java.util.Calendar.

  • Confused - How to Calculate Number of Days Between Dates but Exclude Weekend Dates If There Hasn't Been a Weekend Update

    Hello -
    I've been tearing my hair out over this problem i'm trying to solve, probably just been staring at it too long which is making it worse -
    I have a series of open support tickets which are supposed to be updated on a daily basis, the problem is that they aren't always being updated daily.  So, the business wants to know the number of days from when a ticket was last updated and today's
    date.  I have this basic calculation and it's working fine, however now the business wants to exclude weekends from the calculation.  The other problem is that some reps DO go in on weekends and update their tickets, so sometimes there will be updates
    made on weekend dates.
    To give an example -
    Today's date is 2014-02-10 (Monday).  A ticket was last updated last Thursday, 2014-01-30.  The difference between the two dates is 11, so it's been 11 days since the ticket was last updated.  Now, if I exclude Saturdays and Sundays, then
    it's actually been 7 days since the ticket was last updated.  I'm not sure how to do this in T-SQL.
    Now, to further complicate the problem, sometimes a ticket IS updated on a Saturday or Sunday.  So, if a ticket was updated on 2014-02-02 (Sunday), then it should be counted.  Again i'm not sure how to do this. 
    What gets me is that this is probably fairly simple and i've just been staring at it too long.  In the meantime, can someone offer some guidance?
    Thanks!!

    I've adapted this from a function on my blog. you will need to add set the YourTicketTable to where ever your tickets are stored.
    CREATE
    FUNCTION [dbo].[CalcWorkDaysBetween](@StartDate
    As DateTime,@EndDate
    AS DateTime)
    RETURNS
    INT AS
    BEGIN
    SET @EndDate
    =DATEADD(DAY,1,@EndDate)
    DECLARE @Count
    AS Int= 0
    DECLARE @Date
    As Date=@StartDate
    WHILE @Date
    < @EndDate
    BEGIN
    IF (DATEPART(WEEKDAY,@Date)IN(1,7)
    OR (SELECT
    Count(*)
    FROM YourTicketTable WHERE TicketDate=@Date)=1)
    BEGIN
    SELECT @Count = @Count
    + 1
    END
    SELECT @Date=DATEADD(Day,
    1,@Date)
    END
    RETURN
    DATEDIFF(DAY,@StartDate,@EndDate)- @Count
    END
    Regards,

  • How to get difference in days between 2 dates excluding weekends

    Hi all,
    i have a requirement, to calculate the difference between 2 dates, in days.
    eg: 01/08/2007 and 05/08/2007.
         Difference = 4 days.
    But here my actual requirement is i have to calculate this difference excluding weekends (saturday n sundays).
    eg: 01/08/2007 -
    Thursday
         05/08/2007 -
    Monday
    so now Difference = 2 days.
    Please help me regarding this.
    Points will be rewarded for helpfull answers.
    Thanks in Advance.
    Regards,
    Vineel

    see these codes of rich
    report zrich_0003.
    data: begin of itab occurs 0,
          datum type sy-datum,
          end of itab.
    data: weekday like dtresr-weekday.
    data: number_lines type i.
    parameters: p_sdatum type sy-datum,
                p_edatum type sy-datum.
    itab-datum = p_sdatum.
    append itab.
    do.
      if itab-datum = p_edatum.
        exit.
      endif.
      itab-datum = itab-datum + 1.
      call function 'DATE_TO_DAY'
           exporting
                date    = itab-datum
           importing
                weekday = weekday.
      if weekday = 'Sat.'
        or weekday = 'Sunday'.
        continue.
      endif.
      append itab.
    enddo.
    describe table itab lines number_lines.
    write:/ 'Number of days between dates is', number_lines.
    and
    report zrich_0001.
    parameters: p_start type sy-datum,
                p_end   type sy-datum.
    data: idays type table of   rke_dat with header line.
    data: workingdays type i.
    call function 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
         exporting
              i_datab               = p_start
              i_datbi               = p_end
              i_factid              = 'P8'  " Fact Calender ID
         tables
              eth_dats              = idays
         exceptions
              date_conversion_error = 1
              others                = 2.
    describe table idays lines workingdays.
    write:/ workingdays.
    I want to find the No.of working days between the two dates
    regards,
    srinivas

  • How to get the number of days between 2 given dates

    Hi all,
    How can I find the number of days between any 2 given dates.
    Thanks

    Hi
    Here's a dirty way:
    If you've got two Date objects in Java, call getTime() on each one (which gives you a value in milliseconds), then subtract the two millisecond values, and divide the result by the number of milliseconds in a day (24 * 60 * 60 * 1000). There's more `elegant' ways to do this, but this method only requires one line of Java.
    Best wishes
    Kevin

  • 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);
    }

  • Calculate number of days between two festival dates in payroll schema

    Hi Experts,
    According to my company policy:
    If an empl termination happens before Eid festival of the current year, then the pro-rated Eid bonus (yearly) is based on:
    (The duration between Eid Festival date of previous year - Eid festival date of current year.)/350 days
    Time Evaluation is not implemented in the system. Only payroll is implemented.
    My question: How can I capture the number of days between (Eid Festival date of previous year - Eid festival date of current year) in the payroll schema ?
    Regards,
    Somdeb.

    Hi,
    You can try using date specification. If you update last year eed holiday date for the employee then you can use the operand F along with NUM to get days between last eed holiday and current payroll period last day.
    i.e NUM=FaaT 0
    F is operand to query date specification.
    aa is the date specification.
    T is for unit and it gives number of days
    next space is for current payroll period last day and 0 will reset alternate date to zero if no date specification is mentioned.
    Basically this will give number of days from date mentioned in date type aa to current period last day. For more info you can go through documentation on operand F for NUM.
    Let us know if this helps.
    Regards,
    Poorvi.

  • 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

  • Number of days between 2 dates

    HI,
    I am working on a program that needs to show number of days between 2 dates. When I scanned the function library, I only found a function to give you the number of years between dates. I can probably code this in ABAP but does anyone know if a function exists to do this.

    Hi  Suneela
    Are you concern with the normal dates or do you have any concern with the Factory dates ?
    Lets take both
    1) Normal dates
    It seems that you are trying to get the days between two dates , That you can simply get by subtracting one from the other or else by .
    Assuming that you populated the dates just after the declaration .
    Sample code
                  Data : date1 like sy-datum,
                             Date2 like sy-datum ,
                             No_of_days type i.
                  No_of_days =  date1 – date2.
    Or Else the FM
         Days_between_two_dates
      Sample code
       Data : date1 like sy-datum,
                             Date2 like sy-datum ,
                             No_of_days type i.
    Call function ‘days_between_two_dates’
      Exporting
        I_datum_bis   = Date2   “ Second date
        I_datum_von = date1    “ Start date
    Importing
         E_tage = No_of_days
    Exceptions
      Days_method_not_defined = 1
      Others = 2.
    2) Factory dates
    If You want to find out the difference based on factory calendar
    Then convert the dates to factory calendar dates  first and then simply subtract those factory calendar dates to get  offset days based on factory calendar.
    *Sample code *
       Data : date1 like sy-datum,
                             Date2 like sy-datum ,
                             No_of_days type i.
    data: l_fac_date like  SCAL-FACDATE ,   " Factory calendar: Factory
          l_fac_date2 like SCAL-FACDATE,
          l_fac_date1  like SCAL-FACDATE.
    Perform get_factory_date using date1
                             Changing l_fac_date1.
    Form get_factory_date using l_date
                             Changing l_l_fac_date.
    IF NOT l_date1 IS INITIAL.
       CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
         EXPORTING
      CORRECT_OPTION                     = '+'
           DATE                               = l_date
           FACTORY_CALENDAR_ID                = 'AU' "
        IMPORTING
      DATE                               =
         FACTORYDATE                        = l_l_fac_date
      WORKINGDAY_INDICATOR               =
      EXCEPTIONS
          CALENDAR_BUFFER_NOT_LOADABLE       = 1
           CORRECT_OPTION_INVALID             = 2
           DATE_AFTER_RANGE                   = 3
           DATE_BEFORE_RANGE                  = 4
           DATE_INVALID                       = 5
           FACTORY_CALENDAR_NOT_FOUND         = 6
           OTHERS                             = 7
       IF SY-SUBRC <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    ENDIF.
    Endform.
    Move l_fac_date to l_fac_date1.
    *Do the same for the second date also i.e  . 
    Perform get_factory_date using date2
                             Changing l_fac_date2.
    No_of_days = l_fac_date1 - l_fac_date2.
    Hope this will help you.
    Reward points if helpful

  • 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 fixed date and hire date in schema

    i want to calculate the number of days between a fixed date en the hire date (infotype 041)
    If i read the documentation  right, i should use the following command:
    HRS=YDXA02
    Variable 3 (the x) is the fixed data.
    My question is how do i program the variable x?
    Let's say the date 01.01.2008
    Any help would be welcome

    I assume we are talking about PCR for payroll. In this case look at documentation for operation NUM:
    OOOOOO
    Xnnnnn
    X     Table
    nnnnn Table field
    nn    Date type 'nn' from the Date Specifications infotype (0041)
         Date types are taken from table T548Y.
    Your operation would look like:
      NUM=Faaesb
          F          Fixed indicator for deadline calculation
           aa           Date type: Start date of period to be
                        calculated; if the date type is not 'nn,'
                        the second position is left blank.
             e          Unit, in which the duration is calculated:
                        T = days
                        W = week
    s         End date of period to be calculated:
              (blank)  End of current payroll period
              J        End of current calendar year
              A        Start of current calendar year
              B        Start of WPBP period
             No other specifications are possible.
    So it depends on what kind of fixed date you need.
    Hope it helps,
    Carlos.

  • Number of days between two dates

    I have two dates-String Date1, String Date2(format of both the dates is 'DD-MM-YY'eg;'28-Jan-2008'). I want to find the difference between these dates;ie if value of String Date1 is '28-Jan-2008' and value of String Date2 is '28-Jan-2009', I need to find the number of days between these dates. What need to be done? Can anyone help me out please.
    Thanks in advance for all the help.
    Regards,
    Anees

    Doing a search is a bit ineffiecient. I'd take advantage of the fact that dates are acually stored in milliseconds. Subtract the two millisecond values (Data.getTime()) and divide by the number of milliseconds in a day. One complication, though, is daylight saving time but if you round rather than truncate in the division it should be fine.
    private static final long MILLIS_PER_DAY = 24L * 60L * 60L * 1000L;
    int dayDiff = (int)((date2.getTime() - date1.getTime() + MILLIS_PER_DAY/2)  / MILLIS_PER_DAY);

Maybe you are looking for

  • How can I tell if movie fully downloaded on i-pad

    How can I tell if movie rented from I-tunes fully downloaded  on my Ipad? It only loads partially and then goes to sleep. Continues downloading when I wake it up. Forgot to finish and today I don't see any download pending. But I'm sure it didn't fin

  • XML Schema based form in webdynpro

    Hi I have existing webdynpro which is having an interactive form view. The form is XML schema based. I want to create the same webdynpro with different data structure and different interactive form. Do i need to create the form with XML schema or do

  • Where to find Net8 Assistant?

    The online document tell me that I can run Net8 Assistant in "$ORACLE_HOME/bin/net8asst.sh".But after i install oracle 8,when I try to run the scripts,I can't find it! Who can tell me what is wrong with it? null

  • CProjects 3.1: Project phase can be approved without individual approval

    Hi Guys, My requirement is to prevent cProjects phase from being approved if all of the individual approvers have not given their decisions. I've tried using the customising for phase types to achieve this. Under the setting "Granting of App. with Re

  • Editable RTF output

    we have to generate report in word format, so the user can edit contents of the generated report. Report has lot of formatting needs. To get better idea see this site http://www.buzzle.com/articles/terms-and-conditions-sample.html .. once generated u