Date/Time difference based on working days

Hi Guru's,
       I am having a problem getting the difference between two timestamps. A normal difference between 2 timestamps is possible however i would like to calculate the hour difference between 2 timestamps excluding public holidays, weekends and also after office hours. Is there a series of FM or a logic to extract this kind of info. Hope you guys can shed some light into the matter.
Thanks in advance.
Anand

Hi,
Use FM DATE_COMPUTE_DAY. DATE in MM/DD/YYYY format.
This FM returns the date in form of weekday number ie the date which you give is tuesday then it will return 2.
Give call log date and call handled date.
eg A call is logded on tuesday 3.00 pm and handled on Thursday 10.a.m.
First check the days difference from the return of this FM.
IF the call handled date return - call loged date return is positive means no sat sun , if negative means sat and sun.
then from call logged date time start counting the office hours till call handled time.
Office hours can be easily calculated using 24 hours clock.
For public holidays have to check whether between the twodates any public holiday if is there then subtract that much office hours.
Hope this helps.
Thanks,
Niketa

Similar Messages

  • Function Module for Date/ Time difference in Working Days

    Hi all,
    Are there any function modules which will calculate the difference between a date AND time, but in working days?
    I can use the FIMA_DAYS_BETWEEN_TWO_DATES_2 FM for the dates, but I need to include times in this as well.
    This is for situations where the 'starting date' is a non-working day, and the 'end date' is a working day.  In this situation I need to take all the hours and minutes into account, which happened on the working day.  To give an example -
    Start date:  04.07.2010 (Sunday - Non working day)
    Start time:  21:12:36
    End date:  05.07.2010 (Monday - Working day)
    End time:  04:47:24
    I realise there is a Time option in this function module, but when I test it, it doesn't seem to be returning the desired results (returns 0 for days and time).  I am using '5' as the I_STGMETH and 'GB' as the I_SKALID. 
    I need a calcuation which will return the time, post midnight on the working day - in this example, 4 hours, 47 minutes (seconds are optional!).
    Can anyone help? - can I still use FIMA_DAYS_BETWEEN_TWO_DATES_2 but with different parameters?
    Thanks
    Mischa
    Edited by: Mischa Gulseven on Jul 20, 2010 10:40 AM

    Hi,
    Thanks but this FM does not seem to account for working days.
    For example, if I use:
    DATE1                           04.07.2010  (non working day)
    TIME1                           04:00:00
    DATE2                           05.07.2010   (working day)
    TIME2                           21:00:00
    It will give the following results -
    DATEDIFF                                                      1
    TIMEDIFF                                                     17
    EARLIEST                        1
    I don't want to account for the non-working day so the result I actually want would be to calculate from midnight on 05.07 to 21:00 on 05.07 which should be 21 hours.
    I suspect I probably need to include the STGMETH and the factory calendar somewhere in the FM?
    Does such a FM exist, or could anyone help me with some ABAP for this?
    thanks
    Mischa

  • Date calculations based on working days

    I need to add date calculations to a worksheet to show the time elapsed between two actions.
    Just a straightforward subtraction works fine, but what I really need to be able to do is calculate the number of working days between the two point (as something taking 5 days over Christmas with the 2 bank holidays is different equivalent to something taking 3 days in a normal week)
    At the moment I'm exporting the data into excel for analysis of this, but would really like to be able to do it in Disco so that the end users can go straight to the report using viewer, rather than having to do the conversion for them.
    Is this possible?
    Cheers

    Hi,
    Every thing is possible, the Q is how complicated is it....
    My suggestion is to create a table with all the dates of the non-working days for ex:
    create a table with all the MON-THURSDAYS, union to this table the holidays you know of such as christmas and so on.
    After getting this table you can create a function that returns the number of working days between 1 date to another by subtracting the days exists in this table.
    I started with that, you are more then welcome to get ahead with it and let us know what happened...
    create table holiday
    D_date date,
    d_day varchar2(20)
    create or replace procedure holiday_proc is
    d_date date;
    begin
    d_date := trunc(sysdate);
    while d_date<'01-jan-2010'
    loop
    if to_char(trunc(d_date),'Day') not in ('Saturday ','Sunday ') then
    INSERT INTO Holiday (d_date,d_day)
    (select trunc(d_date),to_char(trunc(d_date),'Day') from dual);
    end if;
    d_date := d_date+1;
    end loop;
    commit;
    end holiday_proc;

  • Calculate Date/Time Difference in a Calculated Column Omitting Weekends, Holidays and Non-Working Hours

    I am looking for a formula to use in a calculated column that calculates the difference between two date/time fields while excluding weekends, holidays and non-working hours
    6/1/2010 9:43 AM - 6/7/2010 1:45 PM
    Here is the closest that I have gotten; however, this formula gives me a result of 96:
    =IF(AND((WEEKDAY([Resolved Date],2))<(WEEKDAY(Created,2)),((WEEKDAY(Created,2))-(WEEKDAY([Resolved Date],2)))>1),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved Date],"D")+1)/7,1))-3),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved
    Date],"D")+1)/7,1)*2))*24)
    Any and all assistance is greatly appreciated!

    I don't know how to exclude holidays but i exclude weekends(Sat&Sun)-
    IF(ISERROR(DATEDIF([Start Date],[End Date],”d”)),””,(DATEDIF([Start Date],[End Date],”d”))+1-INT(DATEDIF([Start Date],[End Date],”d”)/7)*2-IF((WEEKDAY([End Date])-WEEKDAY([Start
    Date]))<0,2,0)-IF(OR(AND(WEEKDAY([End Date])=7,WEEKDAY([Start Date])=7),AND(WEEKDAY([End Date])=1,WEEKDAY([Start Date])=1)),1,0)-IF(AND(WEEKDAY([Start Date])=1,(WEEKDAY([End Date])-WEEKDAY([Start Date]))>0),1,0)-IF(AND(NOT(WEEKDAY([Start Date])=7),WEEKDAY([End
    Date])=7),1,0))
    -Thanks
    Swapnil

  • Payment terms should calculate Payment due date based on working days

    Hi Experts,
    As we know that standard SAP calculates Payment due date= base line date + number of days maintained in payment terms. In this payment days are considered as calendar days and not the working days.
    Example: If base line date is Thursday, payment terms says 3 days then payment due date is calculated as Sunday ( which is not a working day as per the factory calendar I use). The requirement is that payment date should be calculated as following Tuesday considering Satuarday and Sunday are not working days as per the calendar.
    Can you please suggest how can we achieve this?
    Thanks,
    Ravi

    You can not acheive from config pooint of view but you can use BADI and get the solution
    use BAdI MRM_PAYMENT_TERMS to set terms of payment
    You can use this Business Add-In to change the following fields for the 
    terms of payment in the invoice document header:                        
    o  ZFBDT: Base date for due date calculation                            
    o  ZBD1T: Discount days 1                                               
    o  ZBD1P: Discount percentage 1                                         
    o  ZBD2T: Discount days 2                                               
    o  ZBD2P: Discount percentage 2                                         
    o  ZBD3T: Deadline for net condition                                    
    o  ZLSPR: Key for payment block

  • Absence days caliculation based on working days  HR ABAP

    Hi experts,
    I am developing one report that is for Variable Bonus report. We are evaluating the data based on the Variable Bonus period  based on Selection-screen. for ex: 01.04.2007 to 31.03.2008
    There is one record in the IT2001 with begin date 26.01.2008 end date 25.07.2008 for the absence type 0620(Unpaid leave). But our Variable Bonus  period is 01.04.2007 to 31.03.2008. I want to calculate absence days for the above record from 26.01.2008 to 01.04.2008 and 26.01.2008 to 31.03.2008 
    Please let me know any function module which gives me exact absence days.
    i have tried RKE_SELECT_FACTDAYS_FOR_PERIOD... but its giving based on factory id but in my requirement the working days differ from each employee ...for ex:  5 working days in a week or 5.5 working days in a week, 6 working days in a week ....for each employee....
    Please suggest me what could be done to achieve this.....
    <REMOVED BY MODERATOR>
    Thanks in advance....
    Sreenivasa Sarma K.
    Edited by: Alvaro Tejada Galindo on Apr 9, 2008 6:02 PM

    Hi sudheer,
         Thanks for your reply. 
          Yes i need to caliculate the absence days based on S_vbpd(vb period from selection screen). but here in IT2001 Absence day are maintained as contract period ... for example..
    vb period   01.04.2007 to 31.03.2008
    start date                  end date
    25.03.2007     03.04.2007
    20.03.2008     05.04.2008
                  01042007                                          31.03.2008
    ___________|___________________________________|_____
    25032007        03042007     20.03.2008                   05.04.2008
    But system caliculating absence days for period 25.03.2007 to 03.04.2007 and 20.03.2008 to 05.04.2008 in infotype IT2001 total but i need absences from VB period start date and contract enddate(01.04.2007 to 03042007) next period (20.03.2008 to 31.03.2008).
    Please help me for the above scenario.....i hope i made it clear my requirement...
    Regards,
    Sreenivasa sarma k.

  • Adding Date/Time Field + X Number of Days - Basic Calculation Question

    I am assuming this is a basic calculation question. New to Adobe LiveCycle Forms.
    I have a simple form containing a table. The table appears as such:
    Text
    Formatted as Date/Time Fields
    Header 3
    Monday
    user wil choose the beginning date (Date/Time) this is DateTimeField1
    Tuesday
    this should calculate DateTimeField1 + 1
    Wednesday
    this should calculate DateTimeField1 + 2
    Thursday
    this should calculate DateTimeField1 + 3
    Friday
    this should calculate DateTimeField1 + 4
    Saturday
    this should calculate DateTimeField1 + 5
    Sunday
    this should calculate DateTimeField1 + 6
    Calculations are performed after the date is chosen for Monday. My mind tells me the simple calculation of DateTimeField1 + 1 is not going to work (and in fact doesn't!) as it needs to change Monday to a number first. I saw on another thread the following:
    Num2Date(Date2Num(Date(DateTimeField1), "DD.MM.YYYY")+7, "DD.MM.YYYY")
    Thought this was going to get me close. No cigars though!
    Any quick help is greatly appreciated. And since I am new to this, details about what needs to be changed would be great too!
    Thanks

    Here an addition for you date field.
    This FormCalc script in the exit:Event will check it the selected date is on a monday.
    If not it will go the days back until the last monday.
    var Selection = Date2Num($.formattedValue, DateFmt(2))
    var WeekDay = Num2Date(Selection, "E")
    var NewDate
    if (WeekDay eq 1) then
              NewDate = Selection - 6
    elseif (WeekDay eq 3) then
              NewDate = Selection - 1
    elseif (WeekDay eq 4) then
              NewDate = Selection - 2
    elseif (WeekDay eq 5) then
              NewDate = Selection - 3
    elseif (WeekDay eq 6) then
              NewDate = Selection - 4
    elseif (WeekDay eq 7) then
              NewDate = Selection - 5
    else
              NewDate = Selection
    endif
    $ = Num2Date(NewDate, "EEE DD.MM.YYYY")
    Hope this helps, too.

  • Date&Time download appletv not working

    Help !! After successfull configuration of WiFi network and downloading appletv update, appletv tries to download date&time.
    This is ongoing since more then one hour without success. Unfortunately movie downloads do not work without date&time configeration . What can I do ?

    Unplug your Apple TV & disconnect the HDMI cable from the TV.  Try first connecting the HDMI cable to the TV, then the power cord into the socket or back into the Apple TV.

  • Date & Time - Set Automatically Not Working

    I'm experiencing some very quirky behviour with the time that appears on status bar on the home screen and the world clocks.
    Ever since the DST change on the weekend my iPhone no longer acquires the correct time from the network when I have "set automatically" enabled for Date & Time. Prior to this I have traveled through various time zones and the correct time would always be displayed. Even on the World Clocks.
    Now the iPhone acquires time that is -1hr. However, all the World Clocks appear correct (even for the local city that I'm in).
    If I disable "set automatically" and select the city I'm in everything returns to normal and the World Clocks continue to function.
    Since I travel a lot it really bothers me that the set automatically doesn't work and I would really like a long term solution so I can keep it enabled.
    In the meantime, can anyone help explain the following:
    1. How is time stored on the iPhone? Is it set to local time or GMT with a timezone offset?
    2. How does it acquire time and timezone from the carrier?
    3. How does it determine the time to display on the status bar and screen saver?
    4. How does it determine the time to display for the World Clocks?
    I am running firmware 1.1.4

    I am currently in Winnipeg, Manitoba. Current timezone is UTC/GMT -5 (CDT - Central Daylight Time).
    When date & time is set to automatic, the time in the status bar is incorrect for Winnipeg by -1 hr. All the times in the World Clock are correct (including the display for Winnipeg).
    I recall an issue I had when using Bootcamp on my Macbook. The Macbook records system time (and all time stamps) in UTC/GMT but displays the correct time once you specify the timezone offset. This caused problems when booting back and forth with Windows because Windows assumed the system clock was set to the local time (I now use VMWare Fusion). This issue was well documented on the Apple site.
    I'm assuming the iPhone behaves similar to my Macbook and Mac OS and expects the system time to be set as UTC/GMT. The behaviour I'm experiencing suggests the UTC/GMT time is actually being set correctly on the iPhone (otherwise, the world clocks wouldn't display the correct time) but the timezone offset is incorrect for Winnipeg (which determines how it's displayed in the status bar).
    I did some significant troubleshooting last night and gathered some data to further explain the problem. However, I fear that if I post it publicly the thread may be deleted.

  • Payment terms based on working days

    Dear colleagues
    I would like to base payment terms on, for example, the last working day of the month, or the last working day of the trimester instead of working with fixed days.
    Would someone know if this is possible and if so, how can that be arranged?
    Thanks and regards,
    Marlies

    Dear,
    as far as I know, this is not possible into the SAP Standard System.
    I'm sorry about it.
    Mauri

  • Showing current date and the last 250 working days

    Hi,
    we need to report the current day and the last 250 working days. How can I implement this into the BEx by using a variable for the current day selection. How can the selection of the last 250 working days work?
    Thanx
    René

    Hi Rene,
    I think that you have to go for a customer exit variable with multiple selections. The exit will calculate all these work days and place them into output for restriction.
    Best regards,
    Eugene

  • I hate to reinvent the wheel - Date/time differences

    Does anyone have a concise SQL algorithm to find the difference between
    2 dates and times where the dates are stored in a date field and the times are stored as a varchar in the format HH:MM:SS (24 hr clock).

    Hi,
    I am using a stored procedure which give calculates the no of days between two dates. Try using/modifying it and see if it is of any help
    The Procedure................
    DECLARE
         vdDateFrom DATE;
         vnDayFrom NUMBER := 0;
         vnMonthFrom NUMBER := 0;
         vnYearFrom NUMBER := 0;
         vdDateTo DATE;
         vnDayTo NUMBER := 0;
         vnMonthTo NUMBER := 0;
         vnYearTo NUMBER := 0;
         vnYearsDiff NUMBER := 0;
         vnMonthsDiff NUMBER := 0;
         vnDaysDiff NUMBER := 0;
         E_STOP EXCEPTION;
    BEGIN
         vdDateFrom := '01/11/2001';
         dbms_output.put_line('Date From: '||vdDateFrom);
         vdDateTo := '17/11/2001';
         dbms_output.put_line('Date To: '||vdDateTo);
         IF vdDateTo < vdDateFrom THEN
              RAISE E_STOP;
         END IF;
         vnDayFrom := to_char(vdDateFrom, 'dd');
         vnMonthFrom := to_char(vdDateFrom, 'mm');
         vnYearFrom := to_char(vdDateFrom, 'yyyy');
         vnDayTo := to_char(vdDateTo, 'dd');
         vnMonthTo := to_char(vdDateTo, 'mm');
         vnYearTo := to_char(vdDateTo, 'yyyy');
         IF vnMonthTo - vnMonthFrom < 0 THEN
              vnYearsDiff := vnYearTo - vnYearFrom - 1;
         ELSIF vnMonthTo - vnMonthFrom > 0 THEN
              vnYearsDiff := vnYearTo - vnYearFrom;
         ELSE
              IF vnDayTo - vnDayFrom >= 0 THEN
                   vnYearsDiff := vnYearTo - vnYearFrom;
              ELSIF
                   vnDayTo - vnDayFrom < 0 THEN
                   vnYearsDiff := vnYearTo - vnYearFrom - 1;
              END IF;
         END IF;
         dbms_output.put_line('Years: '||vnYearsDiff);
         IF vnMonthTo - vnMonthFrom < 0 THEN
              IF vnDayTo - vnDayFrom >= 0 THEN
                   vnMonthsDiff := 12 + vnMonthTo - vnMonthFrom;
              ELSIF
                   vnDayTo - vnDayFrom < 0 THEN
                   vnMonthsDiff := 12 + vnMonthTo - vnMonthFrom - 1;
              END IF;
         ELSIF vnMonthTo - vnMonthFrom = 0 THEN
              IF vnDayTo - vnDayFrom >= 0 THEN
                   vnMonthsDiff := 0;
              ELSIF
                   vnDayTo - vnDayFrom < 0 THEN
                   vnMonthsDiff := 11;
              END IF;
         ELSE
              IF vnDayTo - vnDayFrom >= 0 THEN
                   vnMonthsDiff := vnMonthTo - vnMonthFrom;
              ELSIF
                   vnDayTo - vnDayFrom < 0 THEN
                   vnMonthsDiff := vnMonthTo - vnMonthFrom - 1;
              END IF;
         END IF;
         dbms_output.put_line('Months: '||vnMonthsDiff);
         IF vnMonthFrom = vnMonthTo THEN
              vnDaysDiff := vnDayTo - vnDayFrom;
         IF vnDaysDiff < 0 THEN
         vnDaysDiff := to_char(last_day(add_months(vdDateTo,-1)),'dd') - vnDayFrom;
                   IF vnDaysDiff < 0 THEN
                        vnDaysDiff := vnDayTo;
                   ELSIF vnDaysDiff >= 0 THEN
                        vnDaysDiff := vnDaysDiff + vnDayTo;
                   END IF;
         END IF;
         ELSE
              vnDaysDiff := vnDayTo - vnDayFrom;
         IF vnDaysDiff < 0 THEN
         vnDaysDiff := to_char(last_day(add_months(vdDateTo,-1)),'dd') - vnDayFrom;
                   IF vnDaysDiff < 0 THEN
                        vnDaysDiff := vnDayTo;
                   ELSIF vnDaysDiff >= 0 THEN
                        vnDaysDiff := vnDaysDiff + vnDayTo;
                   END IF;
         END IF;
         END IF;
         dbms_output.put_line('Days: '||vnDaysDiff);
    EXCEPTION
         WHEN E_STOP THEN
         dbms_output.put_line('Error: Date To is less than Date From.');
    END;
    Regards
    Dinesh

  • Date Time Difference

    Post Author: mrae
    CA Forum: Formula
    I searched for similar topics in this forum and tried several of the formulas but was unsuccessful.  What I'm trying to get is how long from the time a work is requested to the time it's assigned.  So I have to get this information from 4 fields (as the Date and Time are separated):
    Date Requested           Time Requested             Date Assigned             Time Assigned
    1/1/2008 12:00:00 AM    1/01/1900 1:03:00 PM       1/19/2008 5:00:12 AM    1/19/2008 5:00:00 AM
    I tried the DateDiff (intervalType,startDateTime,endDateTime ) and although it gave me the # of days, the hours part does not look right.
    Please help.

    Post Author: mrae
    CA Forum: Formula
    Thanks for your response.   I tried the formula above and was not quite sure if I was doing it correctly.  Since the date and time data I want to capture are in two separate fields (DateRequested and Time Requested), the formula above only has the one field so I tried to insert the Time field by doing this formula below but does not work:
    Local DateTimeVar d1 := ({wrhwr.date_requested}+{wrhwr.time_requested});
    Local DateTimeVar d2 := ({wrcfhwrcf.date_assigned}+{wrcfhwrcf.time_assigned});
    DateDiff ("d", d1, d2) -
    DateDiff ("ww", d1, d2, crSaturday) -
    DateDiff ("ww", d1, d2, crSunday)
    Just as a reference, this is what I get in the Date Field - 1/1/2008 12:00:00AM (note that the time all says 12:00:00AM)
    and this is for the Time Field - 12/30/1899 1:03:00PM (note that all the dates says 12/30/1899).
    Thanks for any help you can give.

  • E71 date problem with alarm on working days

    I've a E71 (firmware : 110.07.127)
    I use the alarm function to wake up me during the week. There is no alarm on week-end. I switch of my phone off every night and on the week end when on saturday i switch it on the date is the friday date. The time is the good one.
    It's a problem because this morning my phone alarm does't work and when i turn my phone on the date was the last sadurday one
    Solved!
    Go to Solution.

    Yes, this is a known problem on S60 3rd Edition. Have a look at this thread.
    FreeBird

  • Date & time  difference in a single column but multiple rows in a table

    hi folks,
    am using Oracle db 10g by chance is there any other way to do my requirement.
    as I stated in my subject.

    You probably need LAG:
    SQL> -- generating sample data (how hard can it be...)
    SQL> with testdata as (
      2  select 200 bno, 32 temperature, to_date('28.05.2012 09:00:00', 'dd.mm.yyyy hh24:mi:ss') dt from
    dual union
      3  select 200, 36,to_date('28.05.2012 15:00:00', 'dd.mm.yyyy hh24:mi:ss') from dual
      4  )
      5  --
      6  -- actual query:
      7  --
      8  select bno
      9  ,      temperature
    10  ,      dt
    11  ,      numtodsinterval(dt-lag(dt) over (partition by bno order by dt), 'day') difference_int
    12  ,      substr((numtodsinterval(dt-lag(dt) over (partition by bno order by dt), 'day')), 12, 8)
    difference_dt
    13  from   testdata;
           BNO TEMPERATURE DT                  DIFFERENCE_INT                 DIFFEREN
           200          32 28-05-2012 09:00:00
           200          36 28-05-2012 15:00:00 +000000000 06:00:00.000000000  06:00:00
    2 rows selected.But, as Paulie already said: still insufficient input. We know nothing about your datatypes. I assumed you're using a DATE.

Maybe you are looking for

  • Best practices for setting up users on a small office network?

    Hello, I am setting up a small office and am wondering what the best practices/steps are to setup/manage the admin, user logins and sharing privileges for the below setup: Users: 5 users on new iMacs (x3) and upgraded G4s (x2) Video Editing Suite: Wa

  • Setup Wizard does not exist on my 8700v... where is it hidden?!

    I have bought a second hand BB, previously on vodafone, currently on O2.  The getting started guide assumes I can find the setup wizard instantly.  Not only does it not appear automatically it is not in settings or any other place I have looked.  The

  • Video Quality Is

    Hello all, I just purchased a Creative Zen (32 GB), and downloaded my first videos to it. I used the conversion software that came with the Zen, and used the Best Video Quality setting. The first time I play a video it looks phenomenal. However, afte

  • Htc one m7 lollipop when Verizon?

    When are you going to approve the Lollipop update for the M7 HTC One ????

  • Give me some advice about the big message

    Whether JMS provider provide the function to deal with big message? i haven't found.Whether should I split the message myself? but if i split myself,the message as a whole will be difficult to ensure whole.I can only receive message one by one.If i o