Run Crontab based on Business Days
I need to set up a job in the crontab to only run on the 2nd, 3rd, 4th, 5th and 8th BUSINESS day (Mon - Fri) of the month. Does anyone know how to do this?
<pre>
I am not sure whether I got it correctly. OK, which I
interprete is you want to the job (lets say it run_my_prog)
to run on 2nd, 3rd, 4th, 5th and 8th day of the month provided
it falls between mon-fri. So it say 4th of the month falls on
sunday, then it should not run. Or otherwise if Friday falls
on 7th day of the month then also it should not run.
I could not find direct way (quickly), so I made a intermediate
script as :
Put this entry in crontab:
15 3 * * 1-5 /etc/myscript
This will run /etc/myscript every mon-fri at 3:15am.
And /etc/myscript would be like this:
#cat /etc/myscript
x=`date | tr -s " " " " | cut -f3 -d " "`
case $x in
2|3|4|5|8) ./run_my_prog ;;
esac
rnu_my_prog will be your intended job. I have not tried this,
but looks like this will work.
Thanks
Kalpesh
</pre>
Similar Messages
-
How to Schedule a Report to Run on a Specific Business Day and Not on the Weekend
Hi,
Is there a way to schedule a Webi report to run on a specific Business Day? For example, if I wanted a report to run on the 3rd day of every month, but when the 3rd day for a particular month landed on a Saturday or Sunday, then Monday would automatically be chosen instead. Is that possible?
Thanks,
MichaelHi Michael,
You can do that by selecting the calendar option while scheduling the report and manually selecting the 3rd day of every month and when the 3rd day for a particular month landed on a Saturday or Sunday, then select the next Monday.
I dont see any option available for this scenario directly in BO.
Regards
Sri Harsha -
How to: Schedule a job to run on the first business day of the month
In Oracle 10.2.0.3, is there a way to schedule a repeating job to run on the first business day of the month? For example, if the first of the month falls on a weekend (such as Saturday, 11/01/2008), I would like the job to run automatically on Monday (for example, 11/03/2008) instead.
set serveroutput on
begin
print_dates('FREQ=MONTHLY;BYDAY=MON,TUE,WED,THU,FRI;BYSETPOS=1;',
to_timestamp_tz('01-JAN-2008 12:00:00','DD-MON-YYYY HH24:MI:SS'), 12);
end;
Gives:
TUE 01-JAN-2008 (001-01) 12:00:00 -07:00 -07:00
FRI 01-FEB-2008 (032-05) 12:00:00 -07:00 -07:00
MON 03-MAR-2008 (063-10) 12:00:00 -07:00 -07:00
TUE 01-APR-2008 (092-14) 12:00:00 -07:00 -07:00
THU 01-MAY-2008 (122-18) 12:00:00 -07:00 -07:00
MON 02-JUN-2008 (154-23) 12:00:00 -07:00 -07:00
TUE 01-JUL-2008 (183-27) 12:00:00 -07:00 -07:00
FRI 01-AUG-2008 (214-31) 12:00:00 -07:00 -07:00
MON 01-SEP-2008 (245-36) 12:00:00 -07:00 -07:00
WED 01-OCT-2008 (275-40) 12:00:00 -07:00 -07:00
MON 03-NOV-2008 (308-45) 12:00:00 -07:00 -07:00
MON 01-DEC-2008 (336-49) 12:00:00 -07:00 -07:00
and the print_dates function is (10.2):
create or replace procedure print_dates
cal_string in varchar2,
start_date in timestamp with time zone,
nr_of_dates in pls_integer
is
date_after timestamp with time zone := start_date - interval '1' second;
next_execution_date timestamp with time zone;
begin
dbms_output.put_line(' -->');
for i in 1 .. nr_of_dates
loop
dbms_scheduler.evaluate_calendar_string
(cal_string, start_date, date_after, next_execution_date);
dbms_output.put_line(to_char(next_execution_date,
'DY DD-MON-YYYY (DDD-IW) HH24:MI:SS TZD TZH TZR'));
date_after := next_execution_date;
end loop;
end;
[\pre] -
Calculation of due date based on Business Days for FICA documents
Hi All,
I am working on project where SD - FICA integration is in picture. We post some charges through SD and FICA document gets posted on relevant Contract Account.
Normally we create Sales Order using transaction VA01 and then we do Billing for this Sales Order through VF01. After billng is done, FICA document automatically gets generated.
We have following requirement to be fulfilled.
For the SD bills posted as above, I want to calculate due date of these bills based on Business Days for FICA document generated (SAP Standard calculate due date based on Calander days). We can use factory calander for calculating business days in relevant function module.
I have checked in the system and it seems that event 1330 ( FM - ISU_DUE_DATE_DETERMINE) is not working in this scenario. Is there any other FM which I can use?
Can anyone help me on this?
Regards,
PradeepHello Praeva ,
The event 1330 has a sample FM FKK_SAMPLE_1330. It doesnt even have a Standard Function Module.
You need to create a Installation-Specific FM and put your code to determine the Due Date based on the logic.
Rgds
Ram Kumar. -
Creating a report subscription to run on the 5th BUSINESS day.
I have a report that needs to send out on the 5th Business day, right now i have it running on the 5th of the month but it needs to change so that it does not send out on the weekends. How do i schedule it to send out on the 5th business day?
Thanks!We have created subscription with One-time Schedule and then created another agent job to execute on 1st working day.
Step 2: execute below to get code that will actually be executed by SQL agent for subscription.
SELECT
'EXEC ReportServer.dbo.AddEvent @EventType=''TimedSubscription'', @EventData='''
+ CAST(RS.SubscriptionID AS VARCHAR(40)) + '''' AS ReportCommand
FROM ReportServer.dbo.ReportSchedule RS JOIN msdb.dbo.sysjobs SJ
ON Convert(varchar(500),RS.ScheduleID) = SJ.name
JOIN ReportServer.dbo.ReportSchedule RSC
ON SJ.name = Convert(varchar(500),RSC.ScheduleID)
JOIN ReportServer.dbo.Subscriptions SU
ON RSC.SubscriptionID = SU.SubscriptionID
JOIN ReportServer.dbo.Catalog CA
ON SU.report_oid = CA.itemid
Join ReportServer.dbo.Users U
on U.UserID = CA.CreatedByID
where CA.Name like 'Test' --Add your report name here
Step 3 : Create another SQL job to execute daily and add below to job step
DECLARE @Today DATE = GETDATE(), @Workingday Date
SELECT @Workingday = CASE DATEDIFF(DAY, '19000101', theDate) % 7
WHEN 0 THEN DATEADD(DAY, 4, theDate)
WHEN 6 THEN DATEADD(DAY, 5, theDate)
ELSE DATEADD(DAY, 6, theDate)
END
FROM (
SELECT DATEADD(MONTH, DATEDIFF(MONTH, '19000101', @Today), '19000101')
) AS d(theDate)
IF @Today = @Workingday
BEGIN
EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription', @EventData='A30C87A9-4AF1-43FA-978A-2AFD05215' --Add output from previous query
END;
Make sure you test above solution as you might have to tweak a bit to work in your environment.
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
How to run procedure/job only on third business day of the month
Hello All,
how can i run the procedure/job only third business day of the month? I am using month table in my procedure and it gets updated only once in month and procedure doesn't need to run everyday.>
how can i run the procedure/job only third business day of the month? I am using month table in my procedure and it gets updated only once in month and procedure doesn't need to run everyday.
>
For such a sparse schedule the easiest way is to DBMS_SCHEDULER and set the 'repeat_interval' using the BYDATE parameter.
See Table 14-7 in chapter 114 DBMS_SCHEDULER of the PL/SQL Packages and Types doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_sched.htm#BABEJGCH
>
Table 114-7 Values for repeat_interval
BYDATE
This specifies a list of dates, where each date is of the form [YYYY]MMDD. A list of consecutive dates can be generated by using the SPAN modifier, and a date can be adjusted with the OFFSET modifier. An example of a simple BYDATE clause is the following:
BYDATE=0115,0315,0615,0915,1215,20060115
The following SPAN example is equivalent to BYDATE=0110,0111,0112,0113,0114, which is a span of 5 days starting at 1/10:
BYDATE=0110+SPAN:5D
The plus sign in front of the SPAN keyword indicates a span starting at the supplied date. The minus sign indicates a span ending at the supplied date, and the "^" sign indicates a span of n days or weeks centered around the supplied date. If n is an even number, it is adjusted up to the next odd number.
Offsets adjust the supplied date by adding or subtracting n days or weeks. BYDATE=0205-OFFSET:2W is
>
The chapter has examples. -
How to fetch the data records in summary format based on previous day
drop table T1;
create table T1(Class, Fees_Collected, Submit_Date) as select
'MBA', 100000, '7/30/2012' from dual union all select
'Btech', 20000, '7/10/2012' from DUAL union all select
'MBA', 45000, '8/1/2012' from dual union all select
'Btech', 55550, '7/31/2012' from DUAL union all select
'BBA', 250660, '7/30/2012' from dual union all select
'MBBS', 44556000, '7/31/2012' from DUAL union all select
'BDS', 420050, '8/1/2012' from DUAL union all select
'BBA', 30450, '7/30/2012' from DUAL union all select
'MBBS', 120450, '7/31/2012' from DUAL union all select
'BDS', 45950, '7/30/2012' from DUAL union all select
'MBA', 252450, '8/1/2012' from DUAL;My requirment is to fetch the records based on summary format to display the data with following columns -
Class |Prev Day Traded Value |Prev Day % of Total |Prev Day % MBA
Note - Previous Day definiton (Buisness Day) = calendar days - (weekends + US Holidays)
Kindly help me, as i want to keep it customized so that without specifying the hard coded dates ( Previous Day) it runs through and provide me the resultset....
All of your help and time is highly appericated.You mean business days I guess ?
I use a function (I had to write it myself) <tt><b> next_business_day(p_start_date in date,p_days_count in number) return date </b></tt>
where I loop forward/backward from p_start_date according to the sign of p_days_count the required number of steps skipping weekends and holidays as the absolute value of p_days_count is mostly under 30 for the rest (at least around here) Oracle's <tt><b> add_months </b></tt> gets it done.
Regards
Etbin
Edited by: Etbin on 6.8.2012 17:55
Year till date: <tt><b> your_date between trunc(sysdate,'year') and sysdate </b></tt> is it ? http://en.wikipedia.org/wiki/Year-to-date ?
Edited by: Etbin on 6.8.2012 18:27
NOT TESTED!
function next_business_date(p_start_date in date,p_count_days in number) return date is
steps number := abs(p_count_days);
retval date := p_start_date;
begin
if p_start_date is null or p_count_days is null then
return to_date(null);
end if;
while steps > 0
loop
/* skipping weekends and (yet to be implemented) holidays */
while to_char(retval,'dy') in ('sat','sun') /* or is_holiday(retval) */
loop
retval = retval + sign(p_count_days);
end loop;
/* retval contains a business day now */
retval = retval + sign(p_count_days);
step := step - 1;
end_loop
return retval;
end; -
Add number of business days to date field
Hello, I noticed that there is not much discussion in the forum surrounding u201Cbusiness daysu201D so I hope this post/discussion/solution contributes to the content of this forum.
I am using the following 3 formulas to try to Add number of business days (based upon a table field) to a specified date:
1. Variable name = SetVar
//Set Variable for Add Business Days:
DateVar Array Holidays;
DateVar Target:= CDate({TMS_MOVEMENT_EVT.EVT_DATE}); // Put your field name in here
NumberVar Add:= {DTCI_DOD_TRANS.TRANS}; // put the number of days here to add (a positive number)
NumberVar Added := (0);
2. Variable name = AddBizDays
//Adding Business Days:
EvaluateAfter({@SetVar});
WHILE Added < Add
Do (target := target +1;
if dayofweek (target) in 2 to 6 and not (target in holidays)
then Added:=Added+1
else Added:=Added);
Target
3. Variable name = HOLIDAYS
//Holiday Array Formula for the report Header:
BeforeReadingRecords;
DateVar Array Holidays := [
Date (2003,12,25), // you can put in as many lines for holidays as you want.
Date (2003,12,31)
0
I am successfully getting my data needed to make the necessary calculations and variable assignmentsu2026 I believe that my ISSUE is that I am not sure where to place these formulas into my report so they assign the variables and execute properly when previewing my report. I am curious if that is my issue, and if so, can someone provide me direction on where to put each of these formulas in my report.
Currently, when I try to preview the report, I get the following Crystal Reports Error: -u201CA number, currency amount, Boolean, date, time, date-time, or string is expected here.u201D
Then Crystal automatically opens the AddBizDays formula and highlights the word added, see below RE: u201CWHILE Addedu201D
For reference, my report has 3 groups, and I am displaying all of my output information (and locating my formulas) in the group footer #3 report section. I have moved them around to other report sections/groups/placements, but to no success.
Thanks so much.
Best, MattI worked this out... FYI - for the benefit of all forum users:
ADDING BUSINESS DAYS TO A CERTAIN DATE (excluding weekends and holidays)
1. Variable name = AddBizDays
//Adding Business Days:
WhileReadingRecords;
DateVar Array Holidays;
DateVar Target:= CDate(); // Put your field name in here
NumberVar Add:= ; // put the number of days here to add (a positive number)
NumberVar Added := (0);
WHILE Added < Add
Do (target := target +1;
if dayofweek (target) in 2 to 6 and not (target in holidays)
then Added:=Added+1
else Added:=Added);
Target
2. Variable name = HOLIDAYS
//Holiday Array Formula for the report Header:
BeforeReadingRecords;
DateVar Array Holidays := [
Date (2003,12,25), // you can put in as many lines for holidays as you want.
Date (2003,12,31)
0
...too bad i don't get forum points for sharing this solution.
Special thanks to KenHamady.com -- for sharing this solution.
Sincerely,
Matt -
How to do running aggr based on prompt value and how to or prompt?
Hello guys
I have some requirements that I have a report that has measures and Months and Date..
1. I have to create dashboard prompts on months and dates in such way that users can select either that want to see monthly sales or daily sales.. So the two prompts should be "or" relationship that point to the same report. If user select month from month prompt, the report will return data at monthly level; if select day on day prompt, it should return data at day level..
2. Doing running sum based on the dates selected from the prompts.
If I select day prompt as between "Feb 12th 2009" and "March 1st 2009", the report should return sales data that is the sum of all sales between "Feb 12th 2009" and "March 1st 2009".. If user select month prompt as between "Nov 2008" and "Feb 2009", the report should show the sum of all the sales from "Nov 2008" and "Feb 2009".
How would I achieve both scenarios?
Any pointer will be greatly appreciated..Hi.
Maybe you want to have dynamic group by in Answers report by choosing group by part from a dashboard prompt.
So, assume this example in which you have only one dashboard prompt that shows Day or Month character data.
Make dashboard prompt:
edit column formula: 1
control: drop-down list
show:
SELECT case when 1=2 then TIMES.CALENDAR_MONTH_DESC else *'Day'* end FROM "Normal model"
union all
SELECT case when 1=2 then TIMES.CALENDAR_MONTH_DESC else *'Month'* end FROM "Normal model"
default to - specified value: Day
set variable - presentation variable: pv_dyn_group_by
label: Group by
Now make report in Answers and we'll use dynamic column for group by depends on our presentation variable (Day or Month):
/* column 1 */
label:
I don't know how to dynamicly change column label (Month or Day) so I put just label Dynamic group by.
column formula:
case when '@{pv_dyn_group_by}' ='Day'
then EVALUATE('TO_CHAR(%1,%2)' as varchar(20), TIMES.TIME_ID, 'dd.mm.yyyy')
else TIMES.CALENDAR_MONTH_DESC
end
/* column 2 */
AMOUNT_SOLD
/* column 3 */
RSUM(AMOUNT_SOLD)
Test:
In both cases we get the same result of RSUM in the end. First we group by a TIMES.TIME_ID if we choose 'Day', second by a TIMES.CALENDAR_MONTH_DESC if we choose 'Month'.
Is that you want to?
So if you want to see month or day values to choose it (between part) you must make second prompt with something like this in show SQL results:
SELECT case when '@{pv_dyn_group_by}{Month}'='Month' then TIMES.CALENDAR_MONTH_DESC end || case when '@{pv_dyn_group_by}{Day}'='Day' then EVALUATE('TO_CHAR(%1,%2)' as varchar(20), TIMES.TIME_ID, 'dd.mm.yyyy') end FROM "Normal model" order by 1
The name of the second prompt is: '@{pv_filter}{Month}'
That will display 'Month' or 'Day'. I don't know better solution :-)
Similar is to make a between 2 prompts.
After then you must modify filter in Answers to get OR (between dates ot between months)
Regards,
Goran Ocko
http://108obiee.blogspot.com/ -
Is there a function to derive "business days" only
Is there either an Oracle SQL built-in function or user-defined function for calculating the difference
between two dates or between SYSDATE and a date in the database, which uses business days
only (at least excluding weekends)?
I'd appreciate any help on this!
Thanks!
Kathy Kuehnle
[ [email protected] ]We solved this with the following package:
create or replace
package body zentr_date_functions as
function eastern (p_year in number) return date is
-- Calculate easter sunday (valid from 1900 to 2099)
-- based on a Gauss algorithm
l_a pls_integer;
l_b pls_integer;
l_c pls_integer;
l_d pls_integer;
l_e pls_integer;
l_p pls_integer;
function make_date(p_d in pls_integer, p_m in pls_integer, p_y in pls_integer) return date is
begin
return to_date(to_char(p_d, '00')||to_char(p_m, '00')||to_char(p_y, '0000'), 'DDMMYYYY');
end;
begin
if p_year not between 1900 and 2099 then
return null;
end if;
l_a := mod(p_year, 19);
l_b := mod(p_year, 4);
l_c := mod(p_year, 7);
l_d := mod(19 * l_a + 24, 30);
l_e := mod(2 * l_b + 4 * l_c + 6 * l_d + 5, 7);
l_p := 22 + l_d + l_e;
if l_p > 31 then
if l_p = 56 and l_d = 28 and l_a > 10 then
return make_date(18, 4, p_year);
elsif l_p = 57 then
return make_date(19, 4, p_year);
else
return make_date(l_p - 31, 4, p_year);
end if;
else
return make_date(l_p, 3, p_year);
end if;
end eastern;
function is_workday (p_date in date) return number as
-- Is p_date a working day?
l_eastern date;
begin
if to_char(p_date, 'DY', 'NLS_DATE_LANGUAGE = AMERICAN') in ('SAT', 'SUN') then
return 0;
end if;
if to_char(p_date, 'DDMM') in ('0101', '0105', '0310', '2412', '2512', '2612', '3112') then
return 0; -- fixed bank holidays in lower saxony, Germany
end if;
if to_number(to_char(p_date, 'MM')) not between 3 and 6 then
return 1;
end if;
if to_number(to_char(p_date, 'YYYY')) not between 1900 and 2099 then
return null;
end if;
l_eastern := eastern (to_number(to_char(p_date, 'YYYY')));
if trunc(p_date) in (l_eastern - 2, l_eastern + 1, l_eastern + 39, l_eastern + 50) then
return 0; -- eastern depentent bank holidays in lower saxony, Germany
end if;
return 1;
end is_workday;
-- This is what you are looking for:
function workdays_between (p_date1 in date, p_date2 in date) return number as
-- count number of workdays between p_date1 and p_date2 (both p_date1 and p_date2 included).
l_count pls_integer := 0;
begin
for i in 0 .. p_date2 - p_date1 loop
l_count := l_count + is_workday(p_date1 + i);
end loop;
return l_count;
end workdays_between;
end; -
Setting Due Date for task using business days
While this may not be new news to many, I found little information on how to add a certain number of business days to determine the due date for a task to be used in a workflow. For SharePoint 2010 environments that cannot run custom code, I have
found a solution that utilizes two additional columns in the task list. The first column I named
Deadline (a number with no decimal places), which will contain the number of business days until a task is to be completed.
The second I named Business Deadline (a calculated column returning a
Date and Time). The formula for the calculated column is:
=[Modified]+INT(ROUNDDOWN([Deadline]/5,0)*7)+ IF(WEEKDAY([Modified]+MOD([Deadline],5))<MOD([Deadline],5), IF(WEEKDAY([Modified]+MOD([Deadline],5)+2)=7,MOD([Deadline],5)+4, IF(WEEKDAY([Modified]+MOD([Deadline],5)+2)=1,MOD([Deadline],5)+3,MOD([Deadline],5)+2)), IF(WEEKDAY([Modified]+MOD([Deadline],5))=7,MOD([Deadline],5)+2, IF(WEEKDAY([Modified]+MOD([Deadline],5))=1,MOD([Deadline],5)+1,MOD([Deadline],5))))
The workflow on create in the task list then is:
Set Deadline to {number of business days}
then Wait for Deadline to equal {number of business days} 'Necessary to ensure the Business Deadline has been set
'then Set Due Date to CurrentItem:Business Deadline
Hope this helps a few others that are beating their heads against their desks like I was.Hi,
Glad to hear that you solve this issue, thanks for your sharing.
Thanks,
Linda Li
Linda Li
TechNet Community Support -
Subtracting/adding Business days
Hi everyone !
I have a calendar question: I have a date, number of days (either business or calendar) and Before/After indicator.
I need to calculate the future/past date depending on business/calendar nn days.
Ideally, I will also read Holidays table to fix the result with Holidays.
Any suggestions ?
CF allows me to know a weekday, add/subtract units from dates, compare dates, but nothing in the direction I mentioned...
Any suggestions will be greatly appreciated !
Gary.Make it very easy on yourself: set up a database table with date as the primary-key, then fill it with 200 years' worth of dates. ("When you run out, dig me up and I'll fix it then ...") You can put any sort of information you want to in there, such as (for example...) a "business-day number" that's used only to calculate these differences. It can literally be anything-and-everything you need to know about dates at your place of business.
When you do this, not only are "complicated calculations" eliminated at-a-stroke, but you can very easily change anything at will. You're simply using an inner-join and ... voila ... the answer is there.
Although setting up a script (in whatever language) to populate the table is a bit tedious, you only need to do it once. To me, it beats every other approach hands-down. -
Calculate "Business Days" and account for holidays
I have played with Date math based on what I have found for documentation, and adding an arbitrary number of days is pretty easy. But what about adding an arbitrary number of business days? I found a web site that talks about "Next business day",
which could be adapted I am sure, but it only accounts for weekends. I want to calculate the date an arbitrary number of business days from a provided date. So, +3 business days calculated from a Monday should produce the date of the following Thursday,
and calculated from a Friday should produce the date of the next Wednesday. And calculated from Friday Sept 4, 2015 (Friday before Labor Day) should produce Thursday Sept 10, 2015.
Given that Windows is very business focused, I wonder if there is some nice hidden .NET functionality to calculate business days based on holidays as well? I know, some offices might give extra days off, four day weekends, etc. But those would be edge case
enough to be safely ignorable for my purposes. Indeed, even holidays could probably be ignored, but if there is a quick approach I would rather use it. If I would need to code some sort of Exchange calendar scraper or some such, I'll live with just accounting
for weekends. ;)You can pull holiday info from outlook.hol file and do the date math based on it. It won't be 100% reliable though. Not all the holidays listed in calendar are non-business days (not in all countries at least). International support may also present additional
issues: in some countries it is a common practice to "move" weekend days to fill a single day gap between holidays and weekend (which screws up next business day calc anyway, regardless of holiday info :-). Not to mention all the possible industry-wide
or company specific policies regarding working days.
Gleb. -
Hi All,
I need to find the calendar date 30 business days back from SYSDATE:
Formula: Calendar Date = SYSDATE - "30 business days"
I have a table contains:
cal_dt,bus_day,holiday
7/1/10,1,NULL
7/2/10,1,NULL
7/3/10,0,NULL
7/4/10,0,NULL
7/5/10,0,'Y'
7/6/10,1,NULL
For the life of me, I can't figure it out how to write the SQL? Please help.
Using Oracle 10g.
Thanks,
MaryThe first query gives you: Today's date - 30 'BUSINESS' days
select cal_dt
from
select cal_dt, bus_day, holiday,
row_number() over (order by cal_dt desc) rn
from calendar
where cal_dt <= TRUNC(SYSDATE)
and bus_day = 1
and holiday is NULL
where rn = 31;
The second query gives you: Last 'BUSINESS' day preceding (Today's date - 30 'CALENDER' days)
Select cal_dt
from (
select cal_dt, bus_day, holiday,
row_number() over (order by cal_dt desc) rn
from calendar
where cal_dt <= TRUNC(SYSDATE-30)
and bus_day = 1
and holiday is NULL
where rn = 1;
Or, you may try a simple alternative to my first query:
select cal_dt
from
select cal_dt, ROWNUM rn
from
select cal_dt, bus_day, holiday
from calendar
where cal_dt <= TRUNC(SYSDATE)
and bus_day = 1
and holiday is NULL
order by cal_dt
where rn = 31;
You may try to run these queries step by step to check what is happening and what suits to your needs. -
Calculate: SYSDATE + TWO BUSINESS DAYS
Is there a simple way (function) in 10g to calculate
- "SYSDATE + TWO BUSINESS DAYS (not including Saturday)"
- "SYSDATE + TWO BUSINESS DAYS (including Saturday)"
in SQL ? Or I have to write a function to calculate manually?
Thank you for any idea.One possible solution, based on a table of holidays:
CREATE TABLE HOLIDAY_TABLE
(HOLIDAY_DATE DATE PRIMARY KEY,
DESCRIPTION VARCHAR2(50));
SELECT dt
FROM (SELECT dt, RANK () OVER (ORDER BY dt) pos
FROM (SELECT TRUNC (SYSDATE) + LEVEL dt,
CASE
WHEN TRIM (TO_CHAR (SYSDATE + LEVEL, 'DAY')) = 'SATURDAY'
OR TRIM (TO_CHAR (SYSDATE + LEVEL, 'DAY')) = 'SUNDAY'
THEN 0
ELSE 1
END cnt
FROM DUAL
CONNECT BY LEVEL < 7) -- number large enough to generate a complete list of possible days
WHERE cnt = 1 AND (SELECT COUNT (*)
FROM holiday_table
WHERE holiday_date = dt) = 0)
WHERE pos = 2 -- number of working days to add Miguel
Maybe you are looking for
-
Is there a way to do batch watermark within iPhoto?
I often upload my photos to pBase using the excellent iPhoto2pBase plugin. But due to the growing issue of photo thefts on the web, I would like to watermark them first. After doing a search on this site, I found recomendations for iWatermark. It's a
-
ITunes on new Mac Mini does not show shared libraries on network or songs on NAS drive
iTunes on new Mac Mini does not show shared libraries on network or songs on NAS drive The latest version of iTunes on a 3-month old Mac Mini (8 gig RAM, OS 10.10.2) does not see any of the shared iTunes libraries on a MacBookPro (MBP) (OS 10.9.5) a
-
HP officejet All in one 4110/ Printer Cartridge
Has this ever happened to anyone. I have changed printer cartridges on my printer so many times with no problems. This last time when I replaced them, I accidentally put the black where the color should go and visa versa, When I discovered this I sta
-
It's weird. The other day I was syncing my iTouch and iPod, when suddenly my computer. Normally it never crashes okay? I thought maybe it was because I was IMing, playing music on iTunes, and syncing, so it was overloaded. When it restarted my iTouch
-
Moving clips between projects, without rendering them
Is this possible? I work on a Macbook Pro, using CS4 production premium. How can I move clips between projects in PP CS4? I KNOW there's a way. Just can't figure it out. Thanks!