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;
Similar Messages
-
How to set the payment Due date calculation as per working days.
how to make changes in the vendor Payment terms so that while calculating the Payment due date as per Payment terms, system calculates it based on Working Days & not the Calender days ?
Help is much appriciated.
Thank you,
AmitHi,
This is the standard settings by SAP, normally we couldn't change it to working day.
Good luck
Tao -
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,
RaviYou 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 -
Delivery Date should propose only working days (Excluding weekends and holidays
Hello All
I have one requirement here, where delivery dates should propose only working days and it should not allow to add weekends and holidays during the creation of sales order.
I would like to know if there are any standard settings to be done in plant or shiping point?
Kindly need all your input on this
Thanks
NaveenHello All
Same calendar has already been assigned in shipping point,plant and sales org and also in the calendar holidays been maintained, even though when we create a sales order it will accept weekends and holidays
Thanks -
Netdue date alteration with next working day
Hi,
I have one report for Accounts Receivables .
In this when net due date falls on holiday, i need to shift this "net due date" to a next working day.
I have one FM "DATE_CONVERT_TO_FACTORYDATE" which i can use for the purpose.
As a input to this FM we need to give Factory calendar ID which is an attribute to Infoobject 0PLANT.
Unfortunately i do not have 0PLANT in my datamodel. But i do have 0COMP_CODE in my datamodel.
As i do not have any link between Factory calendar ID and 0COMP_CODE i am searching for an appropriate solution so that i could use this FM to shift net due date to Next working if the net due date is an holiday.
Any Ideas?Simran
I am not sure if we can get a direct link from 0plant to 0comp_code, but you can enhance the master data of the 0company code to add the factory caledar and load them manually into 0plant.
Let me know if this helps..
Regards,
Avinash -
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 AMHi,
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 -
I need FM calc. days/months/years between 2 dates but computes the work day
I need FM calc. days/months/years between 2 dates but computes the work day.
someone knows ?Hi,
The FM is 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
Check the following example:
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 -
Calculation Based on Previous Day's Figure
Hi all,
This is a solution I implemented several years ago, which is now causing problems and must be rectified. The intention was to compare a single field across two days and calculate the difference. The only way I could figure out how to do that
back then was to go back and loop through the whole table, calculating the difference each day until the present day. This obviously isn't very efficient and now something has gone wrong.
Here's the code:
// Calculates Nett Oil Volume Increase
double previousNettOilVolA = 82433; // value on 2/1/13 which is the live value on the day before this system begins
double previousNettOilVolB = 51347; // value on 2/1/13 which is the live value on the day before this system begins
foreach (DailyTankData tankdata in DataWorkspace.ApplicationData.DailyTankDatas)
if (tankdata.NettOilVolume15TankA != null)//otherwise will crash if null value
tankdata.NettOilVolumeIncreaseTankA = (double)tankdata.NettOilVolume15TankA - previousNettOilVolA;
previousNettOilVolA = (double)tankdata.NettOilVolume15TankA;
tankdata.NettOilVolumeIncreaseTankB = (double)tankdata.NettOilVolume15TankB - previousNettOilVolB;
previousNettOilVolB = (double)tankdata.NettOilVolume15TankB;
This is run on the _Compute event of another property in the table. It seemed to work for a long time, but now is occasionally giving wildly inaccurate numbers.
What's a better way to solve this problem? Failing that, can anyone explain exactly how the above works and why it might be going wrong?
Thanks,
LiamStart by looking at your data. Any unusual spikes or negative values?
A better way to handle it is to let the database do the calculations via a stored procedure. -
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 PMHi 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. -
Baseline date calculation excluding non-Business days
Hi,
We have a requirement to exclude non-Business days while calculating Baseline date.
Currently the Baseline Date being populated in the Accounting Document is Document date + 5days(including Holidays).
For eg
Current Scenario
Document Date: 12th Feb 2008
Baseline date: 17th feb 2008.
Requirement:
Document Date: 12th Feb 2008
Baseline date: 19th feb 2008(Excluding Sat & Sun).
Request you to share useful info in this regard.
Thanks
BinuHi,
Use user exit RV60FUS5 for these base line date calculations.
Thanks
Krishna. -
Help with date calculation based on office hours
Hi,
could you guys point me which way should I think of in PL/SQL, or maybe SQL to calculate a date using not 24 hours day, but office hours.
Let me give you an example
Office hours are between 9am till 5pm
I receive a case - registration time - 14.03.2013 4pm, and I'm supposed to calculate the Due date, let's say Registration time + 10hours.
Normaly I would do "registration time" + 10hours, but I can't. I cannot use 24 hours window for the calculation, but 9am - 5pm window.
So the "Due timestamp" would be = "16.3.2013 10am". Which is : 1 hour from 14.03. + 8hours from 15.3. + 1 hour from 16.3.
Thanks for any ideas.Hi,
A user-defined function would be very handy for that. Foir example
add_office_hours ( in_start_date DATE
, in_num_hours NUMBER
RETURN DATE
DETERMINISTIC ...First, copy in_start_date to a local variable, start_date, and check if start_date is within office hours. If not, change it to the beginning of the next business day.
Add in_num_hours to start_date. Is the result before 5pm on the same day?
If so, the function is finished. Return that date.
If not, find how much past 5pm the result is, and recurse (that is, have the function call itself with a new, later in_start_date and a new, smaller in_num_hours). If you prefer, you can use a loop instead of recursion.
How do you treat weekend and holidays?
Would you want to call the function with a negative number of hours?
If you'd like help. post your best attempt.
Post CREATE TABLE and INSERT statements for a table that you use for testing. The table should have start_date, num_hours and correct_result_date columns.
Always say which version of Oracle you're using (e.g. 11.2.0.3.0).
See the forum FAQ {message:id=9360002} -
Calculating Number of Working Days
Hi All,
I'm creating a crystal report where I have to calculate the Number of Working Days between a date range, this should exclude the Weekends(done) but also exclude the public holidays which have defined in Holidays Calender.
I'm not using procedure , Operating directly with tables.
Any help would be appreciated.
RegardsHello Pari,
Check Exclude Holidays and weekends from Last7Day function link for function to exclude weekends.
and How to query the number of working days between two dates to get holidays defined in holiday calander.
Thanks,
Neetu -
Identifying the date as holiday or working day
hi
if a date is given then how to find, that day is holiday or working day.
plz reply soon.
regards
kqHi..
You can find it by calling the FM <b>DAY_ATTRIBUTES_GET </b>
DAY_ATTRIBUTES_GET : Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuesday), whether the day is a holiday, and more.
reward if Helpful. -
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,
MarliesDear,
as far as I know, this is not possible into the SAP Standard System.
I'm sorry about it.
Mauri -
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.
AnandHi,
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
Maybe you are looking for
-
Deploy Adobe Creative Cloud Enterprise
Anyone deploying Adobe CC ENT in a Windows environment have a script to share that will deploy the exceptions and the build file correctly? I'm using Win7 clients and Server 2008 R2 GPO to deploy. I have a deploy.bat file in the Adobe Creative Cloud\
-
Need some advice on a new build for CS5 Web Premium
I am looking for a powerful PC that I can use mostly for work and some light video work. I have been looking at several systems, but I can't decide if I should get the Core i7 875K, 950 or AMD 1090T for my needs. I typically have many Adobe CS5
-
I understood that I could select a file from a LR collection, start editing it in LR then pass it to CS6 (I chose the option to make a copy and keep the LR changes) , makes the changes in CS6 and save it from CS6 (Saved it as a PSD file) .Afterwards
-
Oracle 11g Rel 2 on Windows 2003
We are trying to install Oracle 11g Rel 2 on a windows 2003 server. But not able to locate the installer on Oracle website. Can anyone please respond whether 11g rel 2 is compatible with windows 2003. Thanks, Samim
-
I try to make a script using the Item choice from a DDList. how I can make it to work? Thanks if DisplayItem(vChoice)="ON"; form1.Page1.HST.rawValue=0.13* form1.Page1.Table1.Row4.Subtotal.rawValue;