Finding the number of days excluding weekends

Dear All,
I want to find the date difference between the working days,
ex, take 2 dates, today - Monday 11th and Monday 18th,
So, I want a function module which will calculate the difference between working days, means from 18th to 11th, it should calculate the difference as 5 working days.
Please let me know the function module which will show the number of difference in working days.
Thanks in Advance,
Ramana

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

Similar Messages

  • How to calculate number of days excluding weekends

    I have the following <u>key figures</u> in my InfoCube:
    Date Released to Vendors key figure - ZRELDT
    Date Awarded to a Vendor key figure - ZAWRDT
    In my BEx query, I need to calculate the difference between these two key figures but the weekends should be excluded.  For example, if the value of ZRELDT is 08/10/2007 (which is a Friday) and the value of ZAWRDT is 08/13/2007, the result should just be 1 day and not 3 days since the other days pertain to a Saturday and a Sunday.
    How do I address this in the formula when creating the Query?
    thanks.

    Hi,
    Use func module HOLIDAY_GET need to pass the Holiday Cal the company use
    and also 
    FM: DATE_CONVERT_TO_FACTORYDATE.
    One way to use this:
    Assuming:
    - You have the start & end dates in variables.
    - Keep a few counters
    Logic:
    - Pass start date to DATE_CONVERT_TO_FACTORY_DATE with the parameter +
    - If this date is not a factory date, the next date which is a factory day is returned. (I.e. passed Sunday as param, got a Monday date returned). If the day passed to the function is the same as the date returned, this is a factory day (working day)
    - If the date passed to the function is not the same as the returned day then this day was not a factory day, meaning not a work date. Add 1 to a counter
    - Pass the first day + 1 (use another counter for + N)
    - Stop loop when passed parameter is equal to stop date.
    You can replicate the factory calendar from R/3, CRM etc in your source system in RSA1 (transfer globals). In your function call, you specify which factory calendar to use
    hope this help

  • Finding the number of days in a given year

    Ok, so i need to figure this one out, been at it for a few days now, but not having much luck with it.
    Ok, so i have:
    public class Project3 {
    public static void main(String [] args) {
    String enteryear = JOptionPane.showInputDialog(null, "Enter a year");
    int yearnum = Integer.parseInt(enteryear);
    so, what i need to do is display an output saying :
    "The year" + enteryear + " has " + days + " in it"
    my problem is that i can not use if then or any other advanced statements, only simple math
    I am having some problems figuring out how to do this.
    I have to keep in mind leap years and follow the rules for finding out if a year is a leap year:
    Div by 4? leap year
    Div by 100? Not a leap year
    Div by 400? Leap year
    but from here, im lost as to how to fit the mnath formula needed.

    There are 365 days in a year. To be exact, there are
    365.25 days in a year.Approximately.
    Time drifts according to our precetion of importance.
    What I mean, is that there is no such thing as a leap
    anything. We created it (time) to suit our needs -
    and is not very acuurate on the overall picture.Er, no. One revolution around the sun is not an integer number of rotations of the earth on its axis. That remainder is the physical basis for leap years and leap seconds.
    Adding time would have extended our current day to be
    well over 1,000,000 hours long since 'time' started.WTF are you talking about? Can I have some of whatever you're smoking?
    Even trying to use to for the most scientifically
    demanding task of placing objects in space at a
    certain time would not be off by not figuring in time
    drift since any time gained would eventually be lost
    again - which is an enigma since time's speed is
    constant, and we invented time to begin with.Seriously dude, you want some Doritos?

  • 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

  • ICal custom repeat every x days EXCLUDING weekends?

    I have an event I would like to repeat every x number of days excluding weekends (so only counting M-F as "counted" days). Is there a way to do this?

    You can exclude Sat/Sun, but they will still be counted - so an occurrence on those days is dropped, and you will get fewer occurrences than you should.
    AK

  • How to find the number of idocs generated for a customer on the basis of his purchase order in a day ?

    How to find the number of idocs generated for a customer on the basis of his purchase order in a day ?

    Dear Friends,
    I am absolutely agree with your answer .
    But my question is,
    Lets say.....
    One customer sending X number of purchase orders in a day , so how many IDocs generated on that specific day for that specific customer .
    So, Question is , How can we find the no of sales orders(IDocs) generated for the customers on the specific day ?
    Hope you all understood my requirement .
    Thanks & Regards,
    Aditya

  • Calculate the number of days in a year excluding Saturday and Sunday

    Hi All,
    I need to get the number of days in a year excluding Saturday and Sunday for HR module and then subtract the public holidays.
    Can some let me know how this needs to be done while loading data from one infocube to another.
    Is there any Function module for the same so that i can write any start routines.
    And also is there any table available for Tcode-SCAL with which i can write any start routines.
    Kindly help me as soon as possible.
    Regards,
    Kumar

    Hi Harish
    Refer to the screenshot for Import and Export parameters
    Code
    FUNCTION ZBI_FM_GET_HOLIDAYS .
    *"*"Local Interface:
    *"  IMPORTING
    *"    VALUE(DATE_FROM) TYPE  SCAL-DATE DEFAULT SY-DATUM
    *"    VALUE(DATE_TO) TYPE  SCAL-DATE DEFAULT SY-DATUM
    *"    VALUE(FACT_CAL) TYPE  SCAL-FCALID DEFAULT SPACE
    *"    VALUE(ONLYFACT_DAYS) TYPE  CHAR1 OPTIONAL
    *"  EXPORTING
    *"    REFERENCE(HOLIDAYS) TYPE  I
    *"  TABLES
    *"      DAY_ATTRIBUTES STRUCTURE  CASDAYATTR
    *"  EXCEPTIONS
    *"      FACTORY_CALENDAR_NOT_FOUND
    *"      HOLIDAY_CALENDAR_NOT_FOUND
    *"      DATE_HAS_INVALID_FORMAT
    *"      DATE_INCONSISTENCY
    DATA: LT_DAY_ATTRIBUTES TYPE TABLE OF  CASDAYATTR WITH HEADER LINE.
    DATA: LV_LINES TYPE SY-SUBRC.
    DATA: DATE1 LIKE DATE_FROM,
    DATE2 LIKE DATE_TO.
    *if from date is gt to date then interchange the dates and multiply the result with -1.
    IF DATE_FROM GT DATE_TO.
    DATE2 = DATE_FROM.
    DATE1 = DATE_TO.
    ELSE.
    DATE1 = DATE_FROM.
    DATE2 = DATE_TO.
    ENDIF.
    CALL FUNCTION 'DAY_ATTRIBUTES_GET'
    EXPORTING
    FACTORY_CALENDAR                = FACT_CAL
    *  HOLIDAY_CALENDAR                = ' '
    DATE_FROM                        = DATE1
    DATE_TO                          = DATE2
    LANGUAGE                        = SY-LANGU
    * IMPORTING
    *  YEAR_OF_VALID_FROM              =
    *  YEAR_OF_VALID_TO                =
    *  RETURNCODE                      =
    TABLES
    DAY_ATTRIBUTES                  = LT_DAY_ATTRIBUTES
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND      = 1
    HOLIDAY_CALENDAR_NOT_FOUND      = 2
    DATE_HAS_INVALID_FORMAT          = 3
    DATE_INCONSISTENCY              = 4
    OTHERS                          = 5 .
    IF SY-SUBRC = 0.
    IF ONLYFACT_DAYS = 'X'.
    DELETE LT_DAY_ATTRIBUTES WHERE FREEDAY EQ SPACE.
    ELSE.
    DELETE LT_DAY_ATTRIBUTES WHERE WEEKDAY LT 6.
    ENDIF.
    DESCRIBE TABLE LT_DAY_ATTRIBUTES LINES LV_LINES.
    HOLIDAYS =  LV_LINES.
    *    IF DATE_FROM GT DATE_TO.
    *      HOLIDAYS = HOLIDAYS * -1.
    *    ENDIF.
    ELSEIF SY-SUBRC = 1.
    RAISE FACTORY_CALENDAR_NOT_FOUND.
    ELSEIF SY-SUBRC = 2.
    RAISE HOLIDAY_CALENDAR_NOT_FOUND.
    ELSEIF SY-SUBRC = 3.
    RAISE DATE_HAS_INVALID_FORMAT.
    ELSEIF SY-SUBRC = 4.
    RAISE DATE_INCONSISTENCY.
    ENDIF.
    ENDFUNCTION.

  • Calculating days excluding weekends

    Msy you please show me how to calculate the number of days in between 2 dates excluding weekends.

    Hi!
    Check out these FM-s:
    K_ABC_WORKDAYS_FOR_PERIODS_GET
    WEEK_GET_NR_OF_WORKDAYS      
    WLB3_GET_NUMBER_OF_WORKDAYS  
    There are some calendar relevant FM-s also. If there's set a production calendar in your SAP, you can check it also.
    SE37 transaction, and search for CALENDAR fm.
    Regards
    Tamá

  • Calculating number of days without weekend and holidays

    Hallo all,
    can someone help me with a formular to calculate the number of days with Crystal Reports 2008 between two dates without weekends and holidays
    eg.
    date one = 03/24/2010
    date two = 03/29/2010
    Result should be 4 days as 03/27 and 03/28 will be a weekend.
    Plus how to exclude holidays ?
    Thank you very much
    Gerald

    As Doug mentioned, Holidays are very location specific, and are you talking about "corporate holidays" where the company is closed, or "public holidays" where banks (<g>) are closed?
    I'd suggest setting up a calendar table (if you don't have one already), one record per date.  You could make it work-days only, days-off only, or all dates with a flag to indicate if it is a work date.  You could then use that to count the number of work days.  By using a table, you wouldn't have to change any code to (a) extend your calendar to the following year, or (b) change holiday dates if the holidays change.  (I'm thinking corporate holidays, where the company might be closed Friday 12/24/10 in observation of Christmas, but would usually only close on the 25th.)
    HTH,
    Carl

  • How to get the number of days of February.....

    Hi ,
    how can I get the number of days (28 or 29) of February of the current year or the next...????
    Or is there any other way to find that a year is a leap or not (i mean the year has 365 or 366 days).??
    Thanks
    Simon

    select add_months(to_date('&v_year', 'YYYY'), 12) -
    to_date('&v_year', 'YYYY') from dual;Jens, it seems we have made the same mistake, trunc usage seems mandatory :
    SQL> ed
    Wrote file afiedt.buf
      1* select add_months(to_date('2007', 'YYYY'), 12) - to_date('2007', 'YYYY') from dual
    SQL> /
    ADD_MONTHS(TO_DATE('2007','YYYY'),12)-TO_DATE('2007','YYYY')
                                                             366
    SQL> ed
    Wrote file afiedt.buf
      1* select add_months(trunc(to_date('2007', 'YYYY'), 'YYYY'), 12) - trunc(to_date('2007', 'YYYY'), 'YYYY') from dual
    SQL> /
    ADD_MONTHS(TRUNC(TO_DATE('2007','YYYY'),'YYYY'),12)-TRUNC(TO_DATE('2007','YYYY')
                                                                                 365
    SQL> Just to clarify my past doubt.
    Nicolas.

  • Can I find the number of times the recorded meeting has been viewed?

    In Adobe Connect is it possible to find the number of views after a recorded meeting is made public? Under meeting dashboard it keeps track of these views for 30 days but I can not seem to find anywhere under the reports where this information is located.

    If you move the recordings to the Content Library, then you can pull the standard content reports for it, which will tell you number of views.

  • How do you work out the number of days difference between two dates?

    I'm running Crystal v12.
    We use a date field in our SQL database that we use to store the client's year end date.
    As the year end date (date and month) doesn't change for a client, the year end date field in all of our reports is set to just show the DD/MM part. Over the years as new clients are set up we just enter the date and month - the year part is irrelevant although as in all date fields the year is automatically entered.
    Doing it this way means that we don't have to adjust the year end year part each year. We just use the DD/MM part.
    I need to create a formula that works out the number of days there have been (i.e. the difference) from the current date to the year end date. It MUST EXCLUDE the year however.
    For example:
    Year End Date = 30/04/03
    Current Date = 25/05/10
    Days Difference (EXCLUDING year) = 25
    Days Difference (including year) = 2582
    Year End Date = 31/03/09
    Current Date = 25/05/09
    Days Difference (EXCLUDING year) = 55
    Days Difference (including year) = 420
    If you include the year part then working out day difference is simply a case of creating a formula that subtracts the year end date from the current date (CurrentDate - {tblClient.YearEnd}.
    HOWEVER I need to exclude the year part.
    Can anyone tell me the formula or best way to do this?
    Thanks in advance.
    Edited by: BadBoy House on May 25, 2010 3:15 PM
    Edited by: BadBoy House on May 25, 2010 3:15 PM

    Hi
    You can try this
    datevar e := date(year(currentdate),month({tblClient.YearEnd}),day({tblClient.YearEnd}));
    numbervar num_days := datediff("d",currentdate,e)
    Create a datevar called e that uses the original month and day numbers for {tblClient.YearEnd} but uses the year of the current date
    Then just datediff on e to get the number of days between the two dates
    I hope i understand your problem and that this helps
    Best regards
    Patrick

  • Determine the number of days in a False period in a Temporal Boolean

    Hi all,
    I need to determiine the number of days based on a condition that lies on the gaps between the periods.
    My input consists of multiple periods. The length of the gap is the condition to determine the start date for summation. However, there can be multimple gaps between my instances that satisfy this condition and I need the last one that satisfies it.
    For example:
    period 1: 1-1-1990 until 31-12-1992
    period 2: 1-1-1994 until 31-12-1996
    period 3: 1-1-1998 until 31-12-1999
    period 4: 1-6-2000 until 31-12-2009
    The condition for the start date is the last gap greater than 1 year. In this example, the start date should be the start date of period 3: 1-1-1998, because this is the period after the last gap >= 1 year. Period 2 also has a previous gap of >= 1 year, but this period should NOT be selected.
    My first idea was to use a TBR function: to determine relevant periods (based on the gaps before and after), calculate the amount of days per relevant period and add those up. However, if I want to do that I need to calculate the number of days in the gaps and I don't see how to do that, since I cannot determine a day difference across periods (end date period 1 until start date period 2).
    Any help/ other solution ideas?
    Kind regards, Els

    This was an interesting puzzle which you can solve from a couple of different angles.
    Firstly, you can use inferred relationships to infer a relationship "the following periods" (ie. the periods that follow the current one). My rules looked like this:
    the period (the other period) is a member of the following periods if
       the other period start date > the period start date
    the period’s next start date = InstanceMinimum(the following periods, the period start date)From here it should be easy to see if there was a gap of more than a year, and find the most recent period after a year-long gap. Of course you need to deal with the situation of the last period, when there is no 'next' period, presumably you would use the date of assessment in that case, but I'll leave that as an exercise for the reader.
    A completely different way of doing it is to use the TemporalConsecutiveDays function to find a date where a gap of 365 days exists, then select periods in which there is a gap immediately before the start of that period. Here are some rules that :
    there is a period that applies if
       ExistsScope(the periods)
          TemporalOnOrAfter(the period start date) and
          TemporalOnOrBefore(the period end date)
    there is a year-long gap if
       TemporalConsecutiveDays(365, 365, there is not a period that applies)
    the period starts after a year-long gap if
       ValueAt(the period start date, there is a year-long gap)
    the start date for calculation = InstanceMaximumIf(the periods, the period start date, the period starts after a year-long gap)Hopefully one of these is suitable for your needs.
    cheers,
    Steve.

  • How can i find the 1st business day of the week ?

    Hi,
    How can i find the 1st business day of the week excluding saturaday,sunday and holidays? i have holiday table which contains the columns name HolidayDate and HolidayDescription.
    Ex:
    10-1-2011 is monday(i.e) 1st business day.check If it is in holiday table,then return the result as 11-1-2011 else return the result as 11-1-2011(which is the first business day of this week).
    Can anyone tell me the Query to solve it?

    Does this help:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (SELECT TRUNC(SYSDATE,'IW') holiday FROM dual
      2  UNION SELECT TRUNC(SYSDATE + 7,'IW') from dual)
      3  SELECT MIN(Dat),wk FROM
      4  (SELECT TO_CHAR(dat,'IW') wk,dat FROM
      5  (SELECT dat + lvl dat FROM
      6  (SELECT TRUNC(SYSDATE,'RRRR') dat, level - 1 lvl
      7  FROM dual
      8  CONNECT BY level <= TO_DATE('31-DEC'||TO_CHAR(SYSDATE,'RRRR')) - TRUNC(SYSDATE,'RRRR'))
      9  ) x
    10  WHERE x.dat NOT IN (select holiday from t))
    11  WHERE TO_CHAR(Dat,'DY') <> 'SAT'
    12  AND TO_CHAR(dat,'DY') <> 'SUN'
    13* group by wk
    SQL> /
    MIN(DAT)  WK
    04-JAN-11 01  -- since 03-JAN-2011 is in holiday list, 04 is taken as first business day of first week
    11-JAN-11 02  -- similar to week 1
    17-JAN-11 03
    24-JAN-11 04
    31-JAN-11 05
    07-FEB-11 06
    14-FEB-11 07
    21-FEB-11 08
    28-FEB-11 09
    07-MAR-11 10
    14-MAR-11 11
    21-MAR-11 12
    28-MAR-11 13
    04-APR-11 14
    11-APR-11 15
    18-APR-11 16
    25-APR-11 17
    02-MAY-11 18
    09-MAY-11 19
    16-MAY-11 20
    23-MAY-11 21
    30-MAY-11 22
    06-JUN-11 23
    13-JUN-11 24
    20-JUN-11 25
    27-JUN-11 26
    04-JUL-11 27
    11-JUL-11 28
    18-JUL-11 29
    25-JUL-11 30
    01-AUG-11 31
    08-AUG-11 32
    15-AUG-11 33
    22-AUG-11 34
    29-AUG-11 35
    05-SEP-11 36
    12-SEP-11 37
    19-SEP-11 38
    26-SEP-11 39
    03-OCT-11 40
    10-OCT-11 41
    17-OCT-11 42
    24-OCT-11 43
    31-OCT-11 44
    07-NOV-11 45
    14-NOV-11 46
    21-NOV-11 47
    28-NOV-11 48
    05-DEC-11 49
    12-DEC-11 50
    19-DEC-11 51
    26-DEC-11 52
    52 rows selected.
    SQL>

  • How can you lower the number of days in IOS8 iPhotos deleted

    In IOS8 photos deleted stay for 30 days. Can you lower the number of days?

    To answer your Subject (rather than the body of your post)
    To get the number of controls, and refs to each, etc, you can combine a
    couple of example VIs and a little index finger grease to make a VI that
    does what you want:
    Help menu >> Find Examples
    Find Example Dialog >>Browse tab
    Programmatically controlling VIs
    Manipulating Applications and VI settings
    Edit Multiple VI Setups.vi
    New Examples for LabVIEW 6.1
    Queues
    Queue Control Seek.vi
    If these two VIs are put in a mixer and shaken (not stirred) you might come
    up with something that tastes write.
    Mike Ashe
    "GL" wrote in message
    news:[email protected]..
    > I need to convert llb from 6i to 6.1 and I am unable to, I beli
    eve
    > because I have to many controls and indicators in the llb.

Maybe you are looking for

  • Wo kann ich noch Adobe Photoshop CS 4 extended herbekommen?

    Hey Leute, ich sucheseit längerem Adobe Photoshop CS 4 extended aber ich finde es nirgendswo zum downloaden. Einen Key habe ich schon etwas länger. Ja legal ! Sonst wäre ich ja ziemlich blöd um mich hier nach der exe umzuschauen. Also da ich Medienge

  • What types of interactive things can CS5 do?

    I know how to create rollovers and disjoint rollovers. Is there anything else interactive that CS5 can make like this? Thanks.

  • What does SOAP action do?

    Hi All, From hep.sap, i have got a very few knoweldge abt SOAP Action. i.e.,"Specify the SOAP action. The action species the value for the SOAPAction in Web service messages.". Can any one elaborate SOAP Action purpose, since we are calling Webservic

  • Messaging Server 4.15 Plug-in API

    I need to convert a messaging server 3.6 plug-in into a messaging server 4.15 plug-in. I got the messaging server 4.15 plug-in API guide. I wrote a plug-in. Building the SMTP plug-in is OK. I installed this plug-in by configuring the SMTP plug-in con

  • Org set up

    Hie, Can you please suggest me for below? I created a new org unit @ PPOMA_CRM..and linked it with R3 sales area, I go to Transaction BP and i m trying to link it with new sales area i have created but it does not appear for selection. Can any one su