Calculate number of working days in a month
Hi All,
I am trying to build a report to calculate the performance of a sales rep for the current month. This report has to exclude the holidays (saturday, sunday and one extra day in each month) in order get the exact performance. Could anyone suggest me on how to go about writing a Case statement which would get me the number of working days in a month excluding holidays.
Thanks
Hi,
There are no direct oracle function that could be used to get the desired results.
However you could try using something like
SELECT COUNT( *)
FROM
(SELECT ROWNUM RNUM
FROM ALL_OBJECTS
WHERE ROWNUM <= TO_DATE('&1') - TO_DATE('&2') + 1
WHERE TO_CHAR(TO_DATE('&2') + RNUM - 1, 'DY') NOT IN('SAT', 'SUN');
Give the two date ranges that you want to look for with the highiest one first. i.e say for example - 01-FEB-2011 to 31-DEC-2010 would give the working days in JAN. However note that you might have to check for holidays related to that country/region (which could be added as a seperate table).
If you need to get an extra day in addition to the weekends, please give the dates accordingly
SQL> SELECT COUNT( *)
2 FROM
3 (SELECT ROWNUM RNUM
4 FROM ALL_OBJECTS
5 WHERE ROWNUM <= TO_DATE('01-FEB-2011') - TO_DATE('01-JAN-2011') + 1
6 )
7 WHERE TO_CHAR(TO_DATE('01-JAN-2011') + RNUM - 1, 'DY') NOT IN('SAT', 'SUN');
COUNT(*)
22
Similar Messages
-
How to calculate number of working days in current month?
hi gurus,
In a customer exit I am trying to check if the system date is the 3rd business day of the current month. Is there any FM module that i can use?
thanks in advance...Use this Function module WDKAL_DATE_ADD_FKDAYS.
-
FM to calculate Number of working days adjusted for an employee -ABAP HR
I have one requirement in which i have to Calculate "Number of working days adjusted" for an employee for a disability program.
In this context i wanna know, if just get difference between two dates (i.e the duration for which employee was compensated ) based on Holiday calender...Will this give give me "Number of working days adjusted" for an employee or i have to consider work schedule for an employee? If yes , Then please let me know sm FM to calculate number of working days between two dates speific to an employee.check
HR_PERSONAL_WORK_SCHEDULE
HR_GET_QUOTA_DATA -
How can i get a number of working days in a month PL/SQL
How can i get a number of working days in a month(excluding Saturday and Sunday) in a query in PL/SQL ?
Please do a search before posting
sql>
select count(*)
from(
select trunc(sysdate,'month')+rownum-1 dy
from all_objects
where rownum <= last_day(sysdate) - trunc(sysdate,'month')+1)
where to_char(dy,'fmday') not in ('sunday','saturday');
COUNT(*)
23
Message was edited by:
jeneesh
Please try yourself to change the query to one that doesn't use a subquery.. -
How to calculate number of working days
Hi experts,
I need to determine the number of working days from two given dates. Below is my example.
1. Posting Date
2. Clearing Date
3. Processing Time in Days
The formula is:
Processing Time in Days = Posting Date - Clearing Date
However, the above result should exclude non-working days such as Public Holidays, Saturdays and Sundays.
This is to be done in my Transfer Rule.
Can someone help me with this.
Points will be assigned as usual.
Thanks!Hi,
With referece to Florin Wach Reply in the following link:
Re: FM to get number of working days in a date range for a calender
Use the update rule(routine) for <i>Processing Time in Days</i> as below:
DATA: date_begin TYPE sy-datum,
date_end TYPE sy-datum,
current_date TYPE sy-datum,
working_indicator TYPE SCAL-INDICATOR,
workdays TYPE I,
factory_calendar TYPE SCAL-FCALID.
date_begin = DATA_PACKAGE-PSTNG_DATE.
date_end = DATA_PACKAGE-CLEAR_DATE.
factory_calendar = '01'.
current_date = date_begin.
DO.
IF current_date > date_end.
EXIT.
ENDIF.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING DATE = current_date
FACTORY_CALENDAR_ID = factory_calendar
IMPORTING
WORKINGDAY_INDICATOR = working_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.
workdays = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
EXIT.
ENDIF.
IF working_indicator IS INITIAL.
ADD 1 TO workdays.
ENDIF.
ADD 1 TO current_date.
ENDDO.
Result = workdays.
With rgds,
Anil Kumar Sharma .P -
Need to calculate number of work days.
Hi Experts,
I have scenario here to calculate the number days between the service request creation date and current date. Since i have the creation date in my cube ( cube is loaded using delta update) , i use formula variable to calculate the difference. But i want to exclude Sunday, Saturday and public holidays.
How can I achive this?
Putting a code in the update rule will help only if we do full update everyday. A delta update will do the calc only once and whenever the base records changes..
So is there any other way i can do this?
Please reply.
DV
nullHi Anuradha,
Hope you haven't understood my issue right.. I will give an eg here.
Lets say we have three new records in base ODS1
[Rec No] [CreatedOnDate(in dd/mm/yyyy)]
(1) ( 06/06/2007)
(2) (11/06/2007)
(3) (15/06/2007)
Assume these are new records that came into ODS1.
Now when we load this into Cube1 from ODS1 with assumption that update between cube1 and ODS1 has a code to calculate the workdays excluding weekends and public holidays. And update method os delta ran yesterday 26/06/2007
So now in the cube1 after yesterdays delta data will look like
[Rec No] [CreatedOnDate] [No of days] [Days w/o weekends/public holidays]
(1) (06/06/2007) (20) (14)
(2) (11/06/2007) (15) (11)
(3) (15/06/2007) (11) (07)
So in the cube if the base records 1, 2 and 3 in ODS1 doesnot chnage the cube after todays delta will have the same value instead of a increment of 1 day in third and fourth column.
Hope I have made my issue clear to all..
DV
null -
Get the number of working days based on factory calendr for a range of mont
Dear all,
We are using BI7.00 . In one of our reports we have the following requirement.
The range of months will be given in the selection screen for example 01.2008 to 11.2008, when the query is executed, i want system to calculate the number of working days for each month of the year (for what values provided in the selection field ) and display the same. i.e., as mentioned below.
Month days.
01.2008 22
02.2008 18
03.2008 25 etc., Kinldy provide steps for adopting the same. If it can be adopted only through customer exit also provide the code and parameters that has to be used.
Regards,
M.Mhi,
Try the following logic to find out the no.of working days in a month based on your calendar.
parameters : mny(6). " input format should be yyyymm
data : d1 like sy-datum,
d2 like sy-datum,
d3 like sy-datum,
v_nds type i.
concatenate mny '01' into d1.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
DAY_IN = d1
IMPORTING
LAST_DAY_OF_MONTH = d2
EXCEPTIONS
DAY_IN_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.
do 30 times.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
CORRECT_OPTION = '+'
DATE = d1
FACTORY_CALENDAR_ID = ' A' " your factory calendar ID
IMPORTING
DATE = d3.
if d1 = d3.
d1 = d1 + 1.
v_nds = v_nds + 1.
else.
d1 = d3.
endif.
if d3 ge d2.
exit.
endif.
enddo.
write : 'No of working days ', v_nds.
hope it helps...
regards,
raju -
Number of working days in customer exit?
Hi, this is actually an extension to the following thread.
How to calculate number of working days
I have very similar requirement. Determine the number of working days (excluding weekends and holidays) from 2 given dates. But the <b>difference here</b> is that, one of the date in the calculation is the<b> current date.</b>
1: Creation Date - this is present as infoobject in the ODS.
2: Current Date - this is 'today''s date.
And, No. of Working days(Zworkdays) = Current Date - Creation Date.
So, as mentioned in the thread 305257 speaks about including the logic in the update rules, I can use system variable sy-datum to get the current date in update routine. But if the load is not scheduled for every day (say,once in 2 days), then when i report this infoobject Zworkdays on Day2, then it will hold Day1 calc rite?
PLease correct me if I am wrong.
Could you please help me with other approachs I can follow. One I can think is Customer Exit in Bex for the same.... but I am not sure how to do the same (i am new to Bex and Customer exit). Could any one of you please guide me how to achieve the same. I Have 0CalDate in the ODS also.
Any other ideas/inputs is greatly appreciated.
Thanks in advance
RamyaHi,
search for virtual key figures.
Rgds.
Juergen
P.S. Thanks for assigning points
Message was edited by:
Jürgen Hemelt -
Finding number of working days during query execution
Hi ,
We have a requirement to calculate number of working days during query execution. In the cube we got "received date", this will be used as a variable in the query. Based on the received date value entered, query needs to display number of products received from past 1, 2,3,4 days (working days should include weekends or public holidays).
1day 2 days 3 days 4 days 5 days
10 12 20 15 20
to me it appears as I need to create virtual key figures.
Regards,
RamzHi ramesh,
First try to create formula variables for start data and end date to calculate the no of working days.
Create a Variable ZSTDT --of type replacement path.
Type of Variable = Formula
Variable Name = ZSTDT
Characteristic = <info object>
For Intervals Use = Select From Value
Offset Start = 0000 Offset Length = 0000
Replacement var with : key
use the same steps to create one more formula variable to get end date.
Now create a formula to get the No of days.
once after getting no of days you can create buckets as per your need.
for more info check the below links
http://www.sd-solutions.com/SAP-HCM-BW-Replacement-Path-Variables.html
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30f15839-0cf1-2b10-c6a7-ebe68cc87cdc?quicklink=index&overridelayout=true -
Number of week days remaining in month
Hi Guys,
I am looking to create a function which returns the number of working days (Monday to Friday) there are between sysdate and the last day of the month.
Has anyone done something similar.
I have tried the following:
<code>
CURSOR days_c
IS
SELECT LEVEL
, to_char(LAST_DAY(ADD_MONTHS(SYSDATE, -1))+LEVEL,'Dy DD-Mon-YYYY') AS DOW --day of week
FROM dual
WHERE ROWNUM <= EXTRACT(DAY FROM LAST_DAY(SYSDATE))
CONNECT BY LEVEL=ROWNUM;
v_cnt NUMBER :=0;
BEGIN
FOR days_r IN days_c
LOOP
IF to_char(days_r.DOW) NOT LIKE 'Sat%' OR to_char(days_r.DOW) NOT LIKE 'Sun%'
--AND to_date(days_r.dow) > sysdate
THEN
v_cnt := v_cnt +1;
END IF;
END LOOP;
RETURN v_cnt;
</code>
At the moment, the IF logic around the days_r.DOW isnt working as I am also struggling to only return dates greater than today but less than the end of the month.
Thanks in advance
Chrisif you don't want to use ALL_OBJECTS
SELECT ROWNUM RNUM
FROM ALL_OBJECTS
WHERE ROWNUM <= DATE_TO - DATE_FROM + 1
you can write code as well as:
CREATE OR REPLACE FUNCTION COUNT_WORK_DAYS(DATE_FROM IN DATE,
DATE_TO IN DATE) RETURN NUMBER
RESULT NUMBER;
BEGIN
SELECT COUNT(*)
INTO RESULT
FROM (SELECT level RNUM
FROM dual
connect by level <= DATE_TO - DATE_FROM + 1)
WHERE (TO_CHAR(DATE_FROM + RNUM - 1, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') NOT IN ( 'SUN', 'SAT')
OR (DATE_FROM + RNUM - 1) IN(SELECT TO_DATE(T.GL_VALUE1, 'DD.MM.YYYY')
FROM CALENDARTABLE T WHERE T.GL_VRB = 'WORKHOLIDAY')) --Getting Holidays which are Working Days from local CalendarTable and calculate as working day
AND (DATE_FROM + RNUM - 1) NOT IN (SELECT TO_DATE(T.GL_VALUE1, 'DD.MM.YYYY')
FROM BSB_GL.GL_VARIABLE T
WHERE T.GL_VRB = 'HOLIDAY') --Getting NATIONAL Holidays from local CalendarTable
RETURN(RESULT);
END GL_COUNT_WORK_DAYS;
Ramin Hashimzade -
Calculate number of Business Days
I need to calculate number of Business Days in BODS. Lets say I have One source table and One Date Dimension table to identify Business Day and need to calculate the no of working days and load in to FACT table (Like in screenshot below)?
By adding Query transform, I can calculate no of Days, but how to calculate working days between ORDER_RECEIVED_DATE and ORDER_SHIPPED_DATE.
SQL: select count(*) from DIM_DATE where DATE between ORDER_RECEIVED_DATE and ORDER_SHIPPED_DATE and HOLIDAY_FLAG='NO'Prashanth Chinta,
I have simulated this Job in my repository and and below are the steps by step implementation.
Your Dataflow will look like below. It contains the source and Target table with expected results. Hope this is what you are looking for.
DIM_DATE table contains all the dates in a year and mark each date either Holiday as 'YES' or 'NO'
Qry_Total_Ship_Days Query Transform
Qry_Join Query Transform
Qry_Filter_Holidays Query Transform
Qry_Cnt_Holidays Query Transform
Qry_Cnt_Holidays Query Transform (This is to show the groupby columns)
Qry_Cal_Ship_Days Query Transform -
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 -
I have to subtract a number of 'working days' of a date field in my message mapping.
I wrote a user defined function. I used cal.add(Calendar.DATE, -3); on the instance cal of the class Calendar. It subtracts 3 days, but I have to subtract 3 'working days'.
Has anyone a suggestion how to achieve this?
Kind regards
FrankFrank,
Since you said that there is FM available in R/3 DATE_CHECK_WORKINGDAY. I would suggest you to do RFC Lookup and get the response if it not working day, then subtract 1 from the current day, and again do lookup to check whether its working day or not. Finally if you get the response as Working day, then subtract 3 from the day(not from the current date, instead the subtracted date , in my previous step).
But it will not solve your issue. The above I said is an approach. Because, consider the below example.
Current day is Saturday, you r doing RFC lookup and getting response as not-working day. Hence on subtracting 1 you will get Friday, now again you are doing RFC look up , this time you will get response as working day , immediately you will subtract 3 from friday, Finally you will get the result as tuesday!!!!
Do you think its correct? Yah sometimes, because while subtracting 3 from friday we have to make sure that thursday & wednesday must not be holiday. I think you got my example, If I'm wrong , please reply me back.
Hope it clears.
The above is an approach, its not the solution. If you look its good we have to apply logic to ahieve the result.
Best Regards,
raj. -
How to create a recurrent event on the first or last work day of the month
The lightning calendar allows selection of the first and last day of the month for recurrent events but for business I need to use the first and last WORK day of the month (Monday - Friday) to schedule particular tasks. In the calendar preferences under 'View' I can select the days that make up the work week but this does not transfer to an option in recurrent events. Is there another way to do this or is it just not available?
Hi there,
do know for the UlltimateBootCD4Win? This from CD bootable WinXP-BartPEedition with additional tools gives you the ability to make such things like partitioning, backup or formatting your HDD.
It has many more applications which help you to maintain your system without booting your original OS.
So I think that this CD will solve your partitioning issues.
Heres a link: www.ubcd4win.com/
Just try it and tell me your opinion.
Nice weekend and greetings from the sunny south ;) -
ABAP - Function module to get the number of working days between 2 days
Hi gentlemen,
I have been asked to produce a report that gives the number of working days between 2 days, based on a calendar.
I didn't find anything...
Has any of you already written a function module to get this ?
A great thanks in advance.
Jacques LagrifHi ,
you can try this ,
when you require the number of working days between D1 and D2
Total No of Days will be
D2 - D1
No of holidays between D1 and D2 , use the FM HOLIDAY_GET
Pass the From date , to date , and the factory calendar to get the of Holidays
Total no of days - Number of Holidays will your Working days
Regards,
Sathya
Maybe you are looking for
-
How to import the data in a .xls or .xlsx file into a oracle database table
Hi, Please tell me how to import the data in a .xls or .xlsx file into a oracle database table in Oracle 10gR2 using Oracle Warehouse Builder 10gR2.
-
ERROR Cannot create target (optional) element - SUPPRESS value
HI, XI/PI experts! I am new in PI 7.1 (Ehp1 SP 7), previously work with PI 7.0. I faced with problem of mapping optional target element, when queue has just SUPPRESS element. I expected to suppressing mapping of the target element, but mapping progra
-
Reader XI - unknown software exception
I have Acrobat Reader XI on a Windows XP SP3 PC. When I open a .pdf file by double clicking on it, before Reader XI runs I get the following error in a pop-up window: The exception unknown software exception (0xc0000409) occurred in the application a
-
Where do I get the firefox toolbar that has all the website page rankings on it?
I had firefox previously on a different comp. I downloaded firefox on a new comp. but the toolbar with all of the website page rankings is not there as it was with my previous version.
-
Applescript flow disrupted in Mountain Lion
Has anyone else had problems with AppleScript in Mountain Lion? I have a script with a repeat loop that looks through every sheet in a Numbers document to gather data from the pages. Previously (in Lion and Snow Leopard) it zipped through the docume