Business Days
I have a simple select statement in SQL. I want to add a column to compare 2 date columns and do business days count, not just days.
Column B 01/15/14 - Column A 01/05/14 = X days removing Saturday and Sunday. Not worries about the holidays.
How can this be done?
See this
http://visakhm.blogspot.in/2010/03/calculating-business-hours.html
just tweak the last part to return days instead of hours
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
Step 5.
5. We need additional time to process your transaction You should get an email from us by next business day. If you don't hear back from us, you can check your order status on your account page or call us at +1 800-585-0774. If you're not in North America, you can look up a local number here. For now, check out all the great free features of Creative Cloud! Get started with trials
I keep getting this.
The Bank and Paypal states that Adobe needs to process my transaction twice.
I have no order number/ no status nor contact from Adobe. I called customer service and he transferred me to sales where the phone rang with no answer.Since this is an open forum, not Adobe support... you need to contact Adobe staff to help
Adobe contact information - http://helpx.adobe.com/contact.html
-Select your product and what you need help with
-Click on the blue box "Still need help? Contact us"
-or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html -
Service Requests-Business days when year changes
Hi All,
I am trying to calculate for how long a SR has been open in business days only.
I have successfully used Mike Lairson's formula for the last 9 months but it seems it cannot cope with year changes. If the begin data is in 2009 and the end date in 2010, the results are not correct anymore.
E.G. For an SR that was opened on 12/30/2009 and closed on 01/05/2010 should return 5 business days but it is actually returning 110.
The syntax that I used so far is:
(CASE
/* Convert Sunday to the Business Day Of the Year */
WHEN DAYOFWEEK("Service Request"."Closed Date and Time") = 1
THEN (DAYOFYEAR("Service Request"."Closed Date and Time") - WEEK("Service Request"."Closed Date and Time")) -
(WEEK("Service Request"."Closed Date and Time") - 2)
/* Convert Saturday to the Business Day Of the Year */
WHEN DAYOFWEEK("Service Request"."Closed Date and Time") = 7
THEN (DAYOFYEAR("Service Request"."Closed Date and Time") - WEEK("Service Request"."Closed Date and Time")) -
(WEEK("Service Request"."Closed Date and Time") - 1)
/* Convert Mon-Fri to the Business Day Of the Year */
ELSE (DAYOFYEAR("Service Request"."Closed Date and Time") -
WEEK("Service Request"."Closed Date and Time")) +
(2 - WEEK("Service Request"."Closed Date and Time")) END)
(CASE
/* Convert Sunday to the Business Day Of the Year */
WHEN DAYOFWEEK("Service Request"."Opened Date") = 1
THEN (DAYOFYEAR("Service Request"."Opened Date") -
WEEK("Service Request"."Opened Date")) -
(WEEK("Service Request"."Opened Date") - 2)
/* Convert Saturday to the Business Day Of the Year */
WHEN DAYOFWEEK("Service Request"."Opened Date") = 7
THEN (DAYOFYEAR("Service Request"."Opened Date") -
WEEK("Service Request"."Opened Date")) -
(WEEK("Service Request"."Opened Date") - 1)
/* Convert Mon-Fri to the Business Day Of the Year */
ELSE (DAYOFYEAR("Service Request"."Opened Date") -
WEEK("Service Request"."Opened Date")) +
(2 - WEEK("Service Request"."Opened Date"))
END)
+
/* Adjust for Year Change */
(365 * (YEAR("Service Request"."Closed Date and Time") -
YEAR("Service Request"."Opened Date")))
Any ideea or hint would be highly appreciated.
Thank you.
Regards,
Dorin
Edited by: user805960 on 06.01.2010 07:07Hi,
i used this formula to find out the days it calculates between 31/12/2009 and 01/01/2010, the result it gave was 106 days.
So i subtracted 106 from 365 days (365-106=259)in the formula, the formula is now giving the correct values.
I think we have to add the total working days and not the no.of days in a year.
Please can you all reconfirm the results.
Thanks
Neena
Edited by: NNK on Jan 11, 2010 3:16 PM -
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 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] -
Can I get a Calendar event to repeat every 4 business days?
I go to a school with a 4-day timetable; that is to say, classes repeat in the same order every 4 days. Is there any way to get events in Calendar to repeat every 4 business days?
I just tested and here is what I get...
-
please i did pay to renew my ios developer account and you sent me an email to reply within 2 business days, but nothing happend yet. may i know what is the problem?
This is primarily a user-to-user support forum and not related to developers. The following link has information about checking your program enrollment: https://developer.apple.com/support/ios/enrollment.html#howcanicheckstatus
If that doesn't help, there is a "Contact Us" button at the bottom of the page in the above link. -
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. -
Oracle 8i: Business Days Calculation in a Subquery
To Whom It May Concern:
I apologize if this has been posted already, but I didn't find any threads that address my issue:
I need to find the number of business days between 2 dates (excludes weekends) provided by dates from an outer query such as the following:
SELECT
C.CUSTOMER_ID
, C.ENTRY_DATE
, C.COMPLETION_DATE
, <SOME SUBQUERY HERE THAT CALCULATES THE NUMBER OF BUSINESS DAYS BETWEEN C.COMPLETION_DATE AND C.ENTRY_DATE> AS BUSINESS_DAYS
FROM CUST_TABLE C
Thanks for your time and advice.
Maxyou don't need a subquery. it's a very simple formula
Re: query regarding dates
(you may need to change the case to a decode for v8 - I don't remember when it was introduced) -
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 -
Formula to calculate due date considering only business days (Middle East)
I have a form which contains two fields: 'Start Date' and 'Completion Date'; the 'Completion Date' field is automatically set, it's always 3 more days than the 'Start Date' field.
The problem is that these 3 days must be only business days.
- if 'Start Date' is on Sunday then the 'Completion Date' should be set to next Wednesday
- if 'Start Date' is on Monday then the 'Completion Date' should be set to next Friday
- if 'Start Date' is on Tuesday then the 'Completion Date' should be set to next Sunday
- if 'Start Date' is on Wednesday then the 'Completion Date' should be set to next Monday
- if 'Start Date' is on Thursday then the 'Completion Date' should be set to next Tuesday
- if 'Start Date' is on Friday then the 'Completion Date' should be set to next Tuesday
- if 'Start Date' is on Saturday then the 'Completion Date' should be set to next Tuesday
Friday and Saturday should be ignored as 'Completion Date' (weekend in Middle East).
Anyone has any idea of how to make this formula? I need to put it into a calculated SharePoint column.
Thanks in advance for your help.Hi
check my post
http://www.romeodonca.ro/Lists/DB_IT/Adding%20a%20number%20of%20working%20days%20to%20a%20specific%20date
If you need more details let me know
Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you. -
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. -
Adding Business Days to a Date to create New Date
I am looking to add a formula to auto calculate a new date, but only want to count business Days.
Currently I am using formula to calculate how many days need to be added:
//ODD Priority Business Days
If left ({DEFECT.PRIORITY}, 1)= "1" then 10
else
If left ({DEFECT.PRIORITY}, 1)= "2" then 20
else
If left ({DEFECT.PRIORITY}, 1)= "3" then 50
else
If left ({DEFECT.PRIORITY}, 1)= "0" then 10
Now I need to create a formula to add these numbers to the date field, for conversation purposes, I need to add these business days to my "start date" to equil my "ODD date".
Example, if my "start date" is 1/1/2009 and it is a Priority 2, then I need to add 20 business days to that, so the "ODD date" would be: 1/29/2009.
Please help.Thank you Garrett Fitzgerald! Please see the modified formula which I meant
{Startdate}
+ {@BusinessDays}
- DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSaturday)
- DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSunday)
Regards,
Raghavendra -
Can I buy an unlock iphone 5 in US now? If I can, how many business days can I get it? Thank you!
Yep, officially for sale now. Apple's online store shows it ships immediately, so should be in stock at just about every Apple store.
-
How can i find the 1st business day of the week ?
Hi,
How can i find the 1st business day of the week excluding saturaday,sunday and holidays? i have holiday table which contains the columns name HolidayDate and HolidayDescription.
Ex:
10-1-2011 is monday(i.e) 1st business day.check If it is in holiday table,then return the result as 11-1-2011 else return the result as 11-1-2011(which is the first business day of this week).
Can anyone tell me the Query to solve it?Does this help:
SQL> ed
Wrote file afiedt.buf
1 with t as (SELECT TRUNC(SYSDATE,'IW') holiday FROM dual
2 UNION SELECT TRUNC(SYSDATE + 7,'IW') from dual)
3 SELECT MIN(Dat),wk FROM
4 (SELECT TO_CHAR(dat,'IW') wk,dat FROM
5 (SELECT dat + lvl dat FROM
6 (SELECT TRUNC(SYSDATE,'RRRR') dat, level - 1 lvl
7 FROM dual
8 CONNECT BY level <= TO_DATE('31-DEC'||TO_CHAR(SYSDATE,'RRRR')) - TRUNC(SYSDATE,'RRRR'))
9 ) x
10 WHERE x.dat NOT IN (select holiday from t))
11 WHERE TO_CHAR(Dat,'DY') <> 'SAT'
12 AND TO_CHAR(dat,'DY') <> 'SUN'
13* group by wk
SQL> /
MIN(DAT) WK
04-JAN-11 01 -- since 03-JAN-2011 is in holiday list, 04 is taken as first business day of first week
11-JAN-11 02 -- similar to week 1
17-JAN-11 03
24-JAN-11 04
31-JAN-11 05
07-FEB-11 06
14-FEB-11 07
21-FEB-11 08
28-FEB-11 09
07-MAR-11 10
14-MAR-11 11
21-MAR-11 12
28-MAR-11 13
04-APR-11 14
11-APR-11 15
18-APR-11 16
25-APR-11 17
02-MAY-11 18
09-MAY-11 19
16-MAY-11 20
23-MAY-11 21
30-MAY-11 22
06-JUN-11 23
13-JUN-11 24
20-JUN-11 25
27-JUN-11 26
04-JUL-11 27
11-JUL-11 28
18-JUL-11 29
25-JUL-11 30
01-AUG-11 31
08-AUG-11 32
15-AUG-11 33
22-AUG-11 34
29-AUG-11 35
05-SEP-11 36
12-SEP-11 37
19-SEP-11 38
26-SEP-11 39
03-OCT-11 40
10-OCT-11 41
17-OCT-11 42
24-OCT-11 43
31-OCT-11 44
07-NOV-11 45
14-NOV-11 46
21-NOV-11 47
28-NOV-11 48
05-DEC-11 49
12-DEC-11 50
19-DEC-11 51
26-DEC-11 52
52 rows selected.
SQL>
Maybe you are looking for
-
I accidently synced my ipod to itunes and all musics are gone
I recently used other program called copytrans manager to transfer musics to my ipod and yesterday I don't know why I did it, but I hit the backup button, assuming that will save my musics files too, and hit the sync! but I felt weird so I canceled t
-
When syncing info from Outlook calendar for notes, the print transfers in black (in most cases). Assume this to be normal However, sometimes info transfers in blue when it was copied from an email and pasted to Outlook notes. Also have added
-
GPEngineException: Error filling role when invoking GP from within webdynpr
Hi I am trying to invoke a guided procedure process (the example Time-Off-process) from within a webdynpro-application. For this, I used the code given here: http://help.sap.com/saphelp_nw2004s/helpdata/en/43/fcdf77fc6510b3e10000000a11466f/frameset.h
-
Application manager update error
I get the updates failed to install. detail says download incorrect try again later. Have tried numerous times with same error. CS5 Win 7 64/32 Screen shot like this
-
Enabling Barcode Reading feature through Forms 6i.
Hi, I would like to get some help from anybody. I would like to add Barcode reading feature in my Inventory Management application written in Forms 6i. Could anyone tell me what exactly i must do to achieve this using Forms 6i's OLE features. If any