Find no. of days between dates

Hi guys,
I have 5 dates with me, 2 of which are Key Figures and 3 are of Char. date type. Now, I have to find no. of days between these dates using various permutation and combination i.e. it can be between 2 KF's or 2 Char. types or 1 KF and 1 Char. type as well.
1) I think finding no. of days between 2 KFs can be done using Cumulative KF.
2) I tried to find no. of days between 2 Charac. by creating a Formula (2 variables with Replacement Path) and then finding the difference. But the output seems to be wrong.
eg. 27.02.2009     -    19.01.2009  = 108 days, which is wrong!
     (Posting date)      (clearing date)
3) I also have to do it between 1 KF and 1 Char. date type, tried creating 1 variable for Char. and then subtracting with KF, but Report shows 'X' in the output!
Any suggestions?
Thanks.

Hi,
You can do it by using Customer Exits and Replacement path Variables..
see teh floowing thread.
Difference in days
Thanks
Reddy

Similar Messages

  • Find year,month & day between dates

    Hi,
       I need to find a number of years, months & day between a given dates. For example If a employee joined on 31.01.2003 and left on 01.06.2006, I need to find in between how many years, months & days he has worked. Is there any function module available .

    DATA: EDAYS LIKE VTBBEWE-ATAGE,
    EMONTHS LIKE VTBBEWE-ATAGE,
    EYEARS LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
    TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    Call Function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
    *   I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Using teh abiove u can get difference but when u pass previous year u wont get the exact.
    There is no seperate FM for this, u have to use three FM.
    If possible using these three FM code u can create an FM.
    <b>For years and months between two days:</b>
    DATA:   EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE PREL-BEGDA,
                     TODATE   LIKE PREL-BEGDA DEFAULT SY-DATUM.
    CALL FUNCTION 'COMPUTE_YEARS_BETWEEN_DATES'
      EXPORTING
        first_date                        = fromdate
    *   MODIFY_INTERVAL                   = ' '
        second_date                       = todate
    IMPORTING
       YEARS_BETWEEN_DATES               =  EYEARS
    * EXCEPTIONS
    *   SEQUENCE_OF_DATES_NOT_VALID       = 1
    *   OTHERS                            = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Write:/ eyears.
    DATA:       EMONTHS LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE SY-DATUM,
                TODATE   LIKE SY-DATUM
    DEFAULT SY-DATUM.
    CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
      EXPORTING
        i_datum_bis         = fromdate
        i_datum_von         = todate
    *   I_KZ_INCL_BIS       = ' '
    IMPORTING
       E_MONATE            = emonths
    write:/ emonths
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
    EXPORTING
    I_DATUM_BIS = x_faede-zfbdt
    I_DATUM_VON = p_fdat
    I_KZ_EXCL_VON = '0'
    I_KZ_INCL_BIS = '0'
    I_KZ_ULT_BIS = ' '
    I_KZ_ULT_VON = ' '
    I_STGMETH = '0'
    I_SZBMETH = '1'
    IMPORTING
    E_TAGE = dias_v.
    IF SY-SUBRC <> 0.
    ENDIF.
    x_faede-zfbdt -> 20050915
    p_fdat -> 20050811
    dias_v = 4
    try this and let me know.
    Message was edited by:
            Judith Jessie Selvi

  • Find No Of Days Between Two Dates

    hello and hi
    me have a data base given below
    me want to find no of days between '16-oct-2008' and '02-NOV-2008'
    Emp Start_Date End_Date
         25551          10/16/2008     10/30/2008
         25551          10/31/2008     11/30/2008
    any body help me pls
    thanks

    Ok, 2 points:-
    1. Simply subtract the two dates and use ROUND
    2. This is an Oracle Forms forum, post query related doubts on SQL/PLSQL forum

  • Function module to find no of days between two dates

    hi everybody i want a function module to find no of days between two dates

    Function module              /SDF/CMO_DATETIME_DIFFERENCE
    Uppercase/Lowercase
    Runtime:        59,629 Microseconds
      Import parameters               Value
      DATE1                           01.01.2007
      TIME1                           00:00:00
      DATE2                           31.12.2007
      TIME2                           00:00:00
      Export parameters               Value
      DATEDIFF                                                    364  TIMEDIFF                                                      0
      EARLIEST                        1

  • 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.

  • To find months and days between 2 dates

    Hi,
    I want to find the months and days between 2 dates.
    For Eg.
    Date-1 : 25-Aug-2013
    Date-2 : 23-Oct-2013
    If we consider every month as 30 days it should give
    25-Aug-2013 to 30-Aug-2013 = 6 days
    01-Sep-2013 to 30-Sep-2013 = 1 Month
    23-Oct-2013 to 30-Oct-2013 =   8 days
    Total = 1 month and 14 days.
    Kindly help at the earliest.
    Thanks & Regards
    Suresh

    SureshM wrote:
    Hi,
    I want to find the months and days between 2 dates.
    For Eg.
    Date-1 : 25-Aug-2013
    Date-2 : 23-Oct-2013
    If we consider every month as 30 days it should give
    25-Aug-2013 to 30-Aug-2013 = 6 days
    01-Sep-2013 to 30-Sep-2013 = 1 Month
    23-Oct-2013 to 30-Oct-2013 =   8 days
    Total = 1 month and 14 days.
    Kindly help at the earliest.
    Thanks & Regards
    Suresh
    That's not a good idea though.  Be considering every month as 30 days, then comparisons over larger date ranges (years) will be out by more and more days the larger the difference gets.
    Your example is also wrong.
    For Eg.
    Date-1 : 25-Aug-2013
    Date-2 : 23-Oct-2013
    If we consider every month as 30 days it should give
    25-Aug-2013 to 30-Aug-2013 = 6 days
    01-Sep-2013 to 30-Sep-2013 = 1 Month
    23-Oct-2013 to 30-Oct-2013 =   8 days
    The last one should be:
    01-Oct-2013 to 23-Oct-2013 = 23 days
    giving a result of 1 month and 29 days.
    Oracle provides a months_between function to do the calculation.
    SQL> select months_between(date '2013-10-23', date '2013-08-25') from dual;
    MONTHS_BETWEEN(DATE'2013-10-23',DATE'2013-08-25')
                                           1.93548387
    But of course, because the number of days in a month varies, it's not exacly known what the decimal part of the number represents.
    However, if you combine methods, using months_between to get the months, and then assume 30 days for a month to get the days part from the remainder, it's more consistent over longer periods...
    SQL> ed
    Wrote file afiedt.buf
      1  with dates as (select date '2013-08-25' as date_from, date '2013-10-23' as date_to from dual)
      2  --
      3  select months_between(date_to, date_from)
      4        ,trunc(months_between(date_to, date_from)) as months
      5        ,round(mod(months_between(date_to, date_from),1)*30) as days
      6* from dates
    SQL> /
    MONTHS_BETWEEN(DATE_TO,DATE_FROM)     MONTHS       DAYS
                           1.93548387          1         28

  • Months and days between dates

    What is the formula to find the months and days between dates

    Tricky... The first problem is the intended result. Months have a varying number of days in them, days and weeks have set values. For example the difference between 1st July and 1st September is 2 months but this does not give an accurate count of the number of days (61).
    It would be better to calculate the number of days difference and forget the months.
    You would need a lookup table showing a numeric value for each date that would show each date with a day value from a starting point. If your earliest date is 01/01/2000 then that would be day zero. Then using the lookup table calculate the day value for your beginning and end dates. Subtract one from the other to get the number of days.
    If all your dates are from this year:
    You can create your own Cell Format (call it day of the year) Select the Type: Date & Time
    drag the icon for Day of Year into the box and delete the others.
    Convert your dates to this new Format, subtract one value from the other to get the number of days difference.

  • 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,

  • Using Formcalc to calculate Days between Dates

    Can anyone give me a simple FormCalc script in which an end date is subtracted from a start date and the result is expressed in number of days?  I'm using LiveCycle Designer ES (not ES2).  Thank you!

    Use the following FormCalc script:
    var numDays;
    numDays = Date2Num("21/5/2012", "DD/M/YYYY") - Date2Num("19/5/2012", "DD/M/YYYY");
    For more details on FormCalc scripting, pelase refer to: http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf

  • How to find no. of days,subtract date -- need help 04/21/2008 - 11/05/2007

    ADAT is internally YYYYMMDD format in table.
    Should i move this field before computation ? IF SO WHAT IS THE FORMAT ,statement pls;
    G_days = ITAB10-ADAT - ITAB11-ADAT.
    04/21/2008 - 11/05/2007 ouput is 54.   ---THIS OUTPUT IS WRONG.
    Any better way of doing this.
    second value 11/05/2007 - 09/10/2007 ouput is 86
    SORT ITAB9 BY ADAT DESCENDING.
    APPEND LINES OF ITAB9 FROM 1 TO 7 TO ITAB10.
    DELETE ITAB9 INDEX 1.
    APPEND LINES OF ITAB9 FROM 1 TO 7 TO ITAB11.
    For eg. : if  02/30/2008 - 02/10/2008 -
    ouput should be 20 days..
    Edited by: Sona on Feb 21, 2008 1:36 AM
    Edited by: Sona on Feb 21, 2008 5:45 AM

    Hi,
    Check the following code:
    REPORT ZDATEDIFF.
    DATA: EDAYS   LIKE VTBBEWE-ATAGE,
          EMONTHS LIKE VTBBEWE-ATAGE,
          EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
                TODATE   LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
      I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Regards,
    Bhaskar

  • Using average days between dates to predict a launch date on another produc

    I hope someone might be able to help me out here.
    I am at the limit of my Webi expertise! (which is not saying a lot)
    We have a universe containing date information relating to the launch of products thus:
    Product Name
    Supplier Name
    Category
    Sample Availability Date
    Testing Start Date
    Launch Go Date
    It is a simple matter to create a variable u2018Project Timeu2019 as DaysBetween(Testing Start Date;Launch Go Date)
    And using the Average function we can create Average Project Length - Also with the Report, and Section keywords we can show the global average, and averages by Supplier and Category.
    Here is my problem.
    We also have Products in the universe that have yet to have their projects kicked off, so Testing Start Date and Launch Go Date for those products are null data. I want to use the Sample Availability Date and the Average Project Length variable to predict the probable Launch Go date, however, in the report this element shows up as an empty cell.
    Does anyone have an idea how I might achieve this?
    Many Thanks
    Mark

    OK...
    Lets imagine there are records for 100 devices in the universe.  75 of them have valid project start dates and launch dates.  25 of them have neither because those projects are yet to start.  However they do have a sample availability date.
    Using the DaysBetween function I can create a variable called project length from the start and launch dates.  I can then use the Average function to get the average project length (for the devices that actually have a project length)
    Somehow I want to add this average project length to the sample availability date on the records that have yet to have a start date.
    As projects end they will add to the average, and we can see how close they were to the predicted launch. As new records are added they will automatically have a predicted date.
    Right now I have the average project length, If I create a table filtering on completed projects (Projects with a non-null launch date) and I add a column showing average project length, because I've used the In Report keyword on the average, it shows the average value in this table.
    If I have a stand-alone cell with the average project length it shows the right value
    But if I have a table showing the devices yet to start (filtering on Null start date) If I add the average project length into that table it shows as blank (I.e. no value at all)
    Hope this helps

  • 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

  • Finding Day from Date i.e. Monday, Tuesday etc

    Hi,
    I need to find out the day from Date. i.e. Monday, Tuesday etc. This is because if the date falls on Saturday or Sunday need to charge difference rates and on weekdays having normal rates.
    Thanks,
    Amol

    We should probably add a function for this as I've certainly seen the requirement before.
    Fortunately it's pretty easy to calculate using a simple rule - the trick is to pick a date in the past that was a Monday, and then use the modulo operator.
    For example:
    The day of the week = (the given date - 1980-01-07) modulo 7
    ie the 7th of January 1980 was a Monday, so every 7th day after that is also a Monday - so combined with the modulo operator this will give you:
    0 monday
    1 tuesday
    5 saturday
    6 sunday
    The only downside is that dates before 1980-01-07 will give a negative modulo (this is distinct from the mathematical modulo operator, but is necessary to be symmetric with the integer division operator truncating towards zero) - so dates before the baseline date will give:
    0 monday
    -6 tuesday
    -2 saturday
    -1 sunday
    You can either choose to write the rules to take this into account, or choose a baseline date so far in the past that it's unnecessary.
    Regards
    Andrew

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

  • Query for difference between dates

    I know I can use the DATEDIFF
    How can I write it if StartDate and EndDate are in these formats?
    StartDate: 2006-09-20 00:00:00.000
    EndDate:   2013-09-20 18:20:53.000
    I want to find the number of days between dates of dates in the two columns

    Those work great, What if I want to use values from a table?
    I have a column called StartDate and a column called EndDate with dates in it. I just what it to show the StartDate in a column, the Endate in column and the number of days in a column.
    Hi,
    Based on your description, do you want to display the following result?
    USE <DatabaseName>
    GO
    --Create a table named DateTest
    CREATE TABLE DateTest
    (StartDate datetime,
    EndDate datetime
    INSERT INTO DateTest
    VALUES ('2006-09-20 00:00:00.000','2013-09-20 18:20:53.000'),
    ('2007-05-06 12:10:09.000','2008-05-07 12:10:09.000'),
    ('2007-05-07 09:53:01.000','2009-05-08 09:53:01.000'),
    ('2008-08-07 05:53:01.000','2010-08-08 05:53:01.000')
    -- Create another table named DateTest1
    SELECT DateTest.StartDate, DateTest.EndDate,
    DATEDIFF(DAY,DateTest.StartDate,DateTest.EndDate) AS days_number INTO DateTest1
    FROM DateTest
    SELECT *FROM DateTest1
    --Below is the result
    StartDate EndDate days_number
    2006-09-20 00:00:00.000 2013-09-20 18:20:53.000 2557
    2007-05-06 12:10:09.000 2008-05-07 12:10:09.000 367
    2007-05-07 09:53:01.000 2009-05-08 09:53:01.000 732
    2008-08-07 05:53:01.000 2010-08-08 05:53:01.000 731
    Thanks,
    Lydia Zhang

Maybe you are looking for

  • Can i save data from a remote server to a client computer?

    written a vi which is used to collect data and store it in a file.data colection is done on a remote system.i am able to control the front pannel frm the client using front panel control in labview 6.1 using web browser. how can i view this data once

  • Recover a 36-hour-old file???

    So, I've done something stupid. My daughter recorded something into GarageBand on Saturday. That night, I was monkeying around with the application-I thought I'd saved and was working with a differently named file, but wasn't-and I... er... screwed u

  • Installing Elements 12

    The last year launched by downloading Elements 12   I try to install on my new Windows 7 64bits system. By clicking on my product the process isn't starting. Akamai Download Manager should start the download. What can I do? William Heres, Holland

  • No option to install/delete/update CS6 apps from Application Manager.

    I have a registered copy of CS6 Master Collection installed on my MacBook Pro running OS X Yosemite 10.10.2.  The Application Manager does not show any options for apps excepts for CC and CC 2014 apps.  Is this how it is supposed to be?  My reason fo

  • How can I turn off Respond with text option on iphone 5s

    I would like to disable the respond with text option, several times while taking the phone out of my pocket I responded to call I wanted to answer