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
Chris
if 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
Similar Messages
-
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.. -
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.
ThanksHi,
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 -
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.
-
Scheduling an Event to Repeat on the i'th week day of each month
Regular repeating, meetings generally fall on the something like the "second Tuesday of each month". This type if option is available on both my Palm devices and Google calendars. Is there a way to do this on the IPhone? It seems like a pretty basic scheduling option to be missing. Does Apple keep a list of enhancement requests and their status?
I know this may not be the way we all want it to work, but if you make your custom repeat on your computer and then sync to the phone, it will work fine. That is, if you make an event in outlook (I'm on a mac so I use iCal, but I'm pretty sure it works the same) and set the repeat to the 2nd Tuesday of each month, when you sync and then look at the event on your iphone, you'll see the repeat is set to "custom", and when you tap the edit button, you'll see that it says "second Tuesday of each month".
I agree this functionality should be in the iphone itself, as it can recognize the repeats, but at least at this point they can't be edited on the iphone itself but for the simple set of choices there. -
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 -
I'd like to know if it's possible to change the number of weeks to be displayed in the month view in calendar? Thanks!
No.
There are up to six calendar weeks that might be used to display the 31 possible days in a month.
So the month view displays six weeks. -
Looking for formula to fill dates of particular days of week for a given month
Hi
I have a Numbers document with a sheet for each month of the year, named "January", "February", "March", etc.
Each sheet contains a table as follows:
I am looking for a function that will calculate the dates in a given month that I am due to see each client, based on the year (contained in a single cell table on a seperate sheet) and the month of the sheet (I am presuming that a function can refer to the name of a sheet). These dates would populate the cells under "Session 1", "Session 2", etc. (for some days of the week there may be only four sessions, for others five).
I hope this is clear, and would be grateful for any help in getting this working.
Thanks,
NickHere's an example, using September, 2011 as the month.
Main Table:
A1: =DATE(Year :: A2,9,1)
This calculates the Date and Time value for midnight at the beginning of the first day of the ninth month of the year indicated in cell A2 of the table "Year" (September 1, 2011). It uses a Custom format to display only the month and year of this date. The Dates calculated in the rest of the table depend on the Date and Time value in this cell.
A2 - A11: Entered data. Not used in calculations.
B2 - B10: Entered data. The text values here are used as search-for values, and must match the text values in column A of the table Weekday lookup.
C2, Filled down to C10: =$A$1+MOD(7-WEEKDAY($A$1)+VLOOKUP(B,Weekday lookup :: $A:$B,2,FALSE),7)
This calculates the Date corresponding to the first occurrence of the weekday indicated in B during the month in A1. The result is a Date and Time value (used in formulas to the right). The cells use a custom format to display only the Day (of the month) number.
D2, Filled right to column F and down to row 10: =C+7
Calculates the date seven days after the date in column C.
G2, filled down to row 10: =IF(MONTH($A$1)=MONTH(F+7),F+7,"")
This is the same formula as used in D2, but adds a check to suppress the calculation if the result is not in the same month as other dates on the table.
Year: The requested single cell table to record the year.
Weekday Lookup: A lookup table from which to retrieve the weekday number for the day in column B of the main table.
Custom formats:
Select cells C2 - G10
Open the Inspector > Cell Format Inspector > Date and Time
Delete the unwanted elements from the workspace in the Inspector.
Repeat for cell A1.
Regards,
Barry
PS: Numbers cannot use the Sheet name or Table name as data for a formula unless the name is placed into a cell on a table.
B -
Outlook 2010 Calendar - Number of weeks displayed in Month view
Is there any way to change the default number of weeks (6) that are displayed in the Month view? On wide screens it leaves very few lines able to be viewed per day. I know I can change the number temporarily by highlighting the number
of weeks I want in the smaller month view in the To-Do Bar, but that view doesn't persist. I also know that I can minimize the ribbon.
I my old Outlook 2003 the default was 5 weeks which was at least a bit better.The real answer is given: No, this is not configurable as it depends on how many weeks a month spans; rarely this is 4 weeks, most often this is 5 weeks, sometimes this is 6 weeks. It is called the "'Month" view, not the "4-weeks view" or anything like
that.
Your feature request is of course valid and to submit it as such, it is best to contact Microsoft Support by phone. You may need to provide credit card information to open a case but it of course won't be charged for a feature request. You'll get a reference
ID so you can track the status of your request.
You may want to refine your request with a business case as well and give a clear example of what you want it to look like and what exactly should be configurable.
For instance, the default Multi-Week View should show; last week, this week and the next 2 weeks.
Robert Sparnaaij
[MVP-Outlook]
Outlook guides and more: HowTo-Outlook.com
Outlook Quick Tips: MSOutlook.info -
Finding the number of weeks or months in a Date range
I have a couple of text boxes that a user inputs a start date and an end date. What I want to know is there a way to tell the number of months or the the number of days in this date range?
For example:
Start Date = 02/12/2004
End Date = 03/12/2004
The number of weeks = 4 //May not be accurate, just showing an example.
The number of months = 2For month, I would define it as the dates that fall in the actual calendar month. If my start date input from the user is 1/21/04, then I want to define a time period of 1/21/04 through 1/31/04 to be included in the first month. I know that it is not an actual month, but I am trying to make graphs based on monthly performance.
For weeks, I want the days to run Sunday through Saturday. If the first date starts on a Wednesday, then I want my first week to include days only Wednesday through Saturday. -
How can I set an event to repeat on a week day rather than a numerical day of each month?
How can I set an event to repeat on a week day rather than a numerical day of each month? I see an option at the bottom of the repeat window .... but I cannot use it. Actually, when I try it freezes up my Calendar.
Lorrene Baum DavisThese scrrenshots are from Snow Leopard - I would think that Lion wouldn't be too much different.
-
I'm trying to calculate the number of days until your next birthday. Only using current month, day and birth month and day. I can get close but i'm way off. When i enter in the next day, the amount of days is supposed to be 364. This is where I am having problems. I know my code is way off. I just need some guidance please!
Attachments:
D5.7_1.vi 8 KBI just had a little fun with the Time Record...
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
D5.7_1_BD.png 19 KB -
Calendar List View Issue - No Month, Week, Day Icons
I'm trying to setup a Calendar view for a list in SharePoint 2010. Everything is working the way I want, except there are no icons to change the view from Month, Week, or Day. Right now, if someone clicks on a date on the calendar, it switches to the Day
view. But there is no way for them to go back to the month view.
I open the page in SharePoint Designer, and in the Design view I can see three icons on the Calendar (Month, Week, Day). But at no time do these icons show up anywhere except the design view.
I want it to have the arrow buttons, the month and year (which are already displaying) and then the icons to change the view. How do I get them to appear?hi,
i was also facing the same problem but some how i solved this by adding 3 buttons for day,week,month and added javascript. it worked for me
i placed the buttons just above the webpart content place holder
u try like that.
<input name="Week" type="button" value="Week" onclick="Test()" />
<input name="Day" type="button" value="Day" onclick="TestDay()" />
<input name="Month" type="button" value="Month" onclick="TestMonth()" />
At the page end page in designer
<script type="text/javascript">
function Test()
CoreInvoke('MoveView','week');
function TestDay()
CoreInvoke('MoveView','day');
function TestMonth()
CoreInvoke('MoveView','month');
</script> -
Day of the week and the day of the month out of sync
I'm not sure this is the right forum to post this, so I apologize in advance.
When I open iCal on my iPhone 4 in day view I see Oct 29 with a W for Wednesday on top of it although below the days of the month it reads: Tuesday, October 29, 2013.
Is anyone experiencing this problem? Any solution?
TIAThanks for replying, ChrisJ4203. It's defintely a problem with Brazilian users. Here's a workaround a countryman posted:
I've managed to fix it:
Go to Settings / Mail Contacts and Calendars / Start the week on
Change from Sunday to Monday.
It appears people in Brazil are the only ones affected.
It's a good work-around while apple does not fix this bug.
Mesmo problema aqui. Como consertar:
Ajustes / Mail contatos e calendários / Iniciar a semana em:
Mude de "Domingo" para "Segunda"
Parece que somente pessoas no Brasil foram afetadas.
É uma boa forma de contornar enquanto a Apple não repara a bug.
iPhone 5 - iOS 7.0.3 -
Schedule Executed weekly except for a specific day of the month
Hi all,
I need to create a schedule that run weekly every sunday at 9 PM, except for 2nd day of the month it will run at 7 AM.
I have created 2 schedules:
1. One to run weekly every sunday at 9 PM, but i don't know from where i can specify the days of the month the schedule will be inactive on it.
* I have tried By Month Day option, and choose all days of the month except second day of the month to run on it.
FREQ=WEEKLY; BYMONTHDAY=1,3,4,5,..,31; BYDAY= SUN; BYHOUR=21;
But, on the schedule preview window as i have designed the schedule from oracle warehouse builder, shows sunday, 02, July for example.
as an execution date for this schedule.
which is not appropriate.
2. Another job is created to run monthly on the 2nd day of the month,
FREQ=MONTHLY; BYMONTHDAY=2; BYDAY= SUN; BYHOUR=7;
So, please advice how to create schedules daily or weekly and neglect some days of month from it.Hi,
You can use the exclude clause introduced in 10gR2 for this by creating a schedule when your job should not run and excluding it. An example is given below.
Hope this helps,
Ravi.
create or replace procedure print_schedule_dates
schedule in varchar2,
start_date in timestamp with time zone default dbms_scheduler.stime(),
number_of_dates in pls_integer default 10
is
date_after timestamp with time zone := start_date - interval '1' second;
next_date timestamp with time zone;
begin
for i in 1 .. number_of_dates
loop
dbms_scheduler.evaluate_calendar_string
(schedule, start_date, date_after, next_date);
dbms_output.put_line(to_char(next_date,
'DY DD-MON-YYYY (DDD-IW) HH24:MI:SS TZH:TZM TZR'));
date_after := next_date;
end loop;
end;
begin
dbms_scheduler.create_schedule('monthday2',
repeat_interval=>'freq=monthly;bymonthday=2');
end;
exec print_schedule_dates('FREQ=WEEKLY;BYDAY=SUN;BYHOUR=21;exclude=monthday2',sysdate+1,30);
exec print_schedule_dates('FREQ=WEEKLY;BYDAY=SUN;BYHOUR=21',sysdate+1,30);
Maybe you are looking for
-
Finally Found a Solution to the Missing Palettes/No Screen update problem!
Ever since CS3 came out, Photoshop and Illustrator in particular (the worst offenders) wouldn't run properl y on my system unless I did a full reboot before running either. Photoshop would load, but all palettes would be empty. Illustrator would forg
-
Any help to rest it is appreciated
-
Can't install windows 8.1 on 2015 MacBook pro
I'm trying to install windows 8.1 with boot camp and this is the message I keep getting. I've tried several times and every time I get this. I have a 2015 MacBook Pro. I've tried installing from a usb with ISO and also from a oem windows dvd. Any hel
-
I have just managed to trasnfer all docs from old Dell to new iMac, and I have discovered that during the process it has created a new user. How do I move the docs from my iMac user to iMac user created yesterday? Is it possible to copy file from us
-
What causes my IMac (OS X 10.8.3) to have trouble playing VIdeo?
I am unable to play any internet video without many stops which may or may not resume. I have used ONYX to clean the drive but it made little if any difference. It is not my wifi connection since I have no trouble with video on my IPad or my TV. Any