Need to return Business Days

Post Author: latingntlman
CA Forum: WebIntelligence Reporting
I have two date fields:  EstDateofDeparture and  EstDateofArrival.
My problem is when EstDateofDeparture falls on a Friday then EstDateofArrival shows on a Saturday and we don't deliver on Saturdays.We do have departures on Saturdays but no pickups on Sats and sundays.
So I need the EstDateofArrival to be the following business day (Monday).Here's an example below:
EstDateofDeparture:  Friday, Dec 7th, 2007EstDateofArrival:       Saturday, Dec 8th, 2007  (it needs to be Monday, Dec 10th, 2007 -- next business day).
Example # 2:
EstDateofDeparture:  Saturday, Dec 8th, 2007EstDateofArrival:       Sunday, Dec 9th, 2007  (it needs to be Monday, Dec 10th, 2007 -- next business day).
T-SQL has a functionalilty where you could for example add getdate()-1 or getdate()+2.
But I can't find anything in webi formula editor that shows me how to I can do that.
Is there a function for this??
thx,
John

Post Author: jsanzone
CA Forum: WebIntelligence Reporting
John,
You will need to use a combination of two functions:
=If(DayName([EstDateofDeparture])="Saturday";RelativeDate([EstDateofDeparture];2); if(DayName([EstDateofDeparture])="Sunday";RelativeDate([EstDateofDeparture];1);   [EstDateofDeparture]))
Use the DayName() function to determine if it is a Saturday (and if so add two days, else add 1 day for a Sunday), and use the RelativeDate() function when adding days to a date.  If the day is neither Saturday or Sunday then leave the EstDateofDeparture in-tact.

Similar Messages

  • Need Help Calculating Business Days AND omitting Holidays...

    Post Author: dkotenoglou
    CA Forum: Formula
    Thanks to the people here I was able to get a nice formula to help me calculate the amount of business days between two days.//Crystal syntax
    Local DateTimeVar d1 := ;
    Local DateTimeVar d2 := ;
    DateDiff ("d", d1, d2) -
         DateDiff ("ww", d1, d2, crSaturday) - 
         DateDiff ("ww", d1, d2, crSunday) This works great.  I wanted to add the ability to omit US Holidays.  Now this is a straight Crystal Reports install without an SQL backend so I cannot use any formulas there.Is there a parameter? I can use to manually create a table of dates to omit?  The only reason I ask is that our company was closed during the holidays so my day reports are really high. I do not mind typing a long list of days manually (12/24/2007, 12/25/2007, etc) but I need to know how to best integrate that list into the formula.  

    Post Author: V361
    CA Forum: Formula
    If you have CR XI, there is another example as well, in the sample reports,  look at feature examples, custom functions.rpt   this code is from that example.
    Function cdDateAddSkipHolidays (nWorkingDays As Number, startDateTime As DateTime) As DateTime    'the result = startDateTime + nWorkingDays + nHolidays (including weekends)    'the algorithm below also works when nWorkingDays is negative
        Dim totalDays    'give a rough estimate for total days. For each 5 work days there are 7    'days. Also add in an extra 2 weekend days to account for a partial week.    totalDays = Fix(nWorkingDays * 7 / 5 + 1) + 2
        Dim iteratedDiff    iteratedDiff = cdDateDiffSkipHolidays (startDateTime, startDateTime + totalDays)
        If (iteratedDiff >= nWorkingDays) Then        Do While iteratedDiff >= nWorkingDays            totalDays = totalDays - 1            iteratedDiff = cdDateDiffSkipHolidays (startDateTime, startDateTime + totalDays)        Loop        cdDateAddSkipHolidays = startDateTime + totalDays + 1    Else        Do While iteratedDiff < nWorkingDays            totalDays = totalDays + 1            iteratedDiff = cdDateDiffSkipHolidays (startDateTime, startDateTime + totalDays)        Loop         cdDateAddSkipHolidays = startDateTime + totalDays    End If
    End Function

  • Help with expression for business days

    Dear Frends,
    I need help with business days expression.
    The report is for call center operation. Whenever a user calls in and opens an issue it is recorded as a case. And each case is associated with create time and valueofone(which is always one).
    My report contains 'case type' as the first column, and rest of the columns are age buckets(col1: 0-5 days, col2: 6-10 days). By saying agebuckets I mean number of days between create date and current date. All the cases that are less than 5 days older will go to first column and similarly all the cases that are 6-10 days old will go to the second column and so on.
    In a normal case I use the following case statement: case when daysbetween(current_date, create_date) between x1 and x2 then count(valueofone) else null end
    But I need to calculate only the business days as age, so I need an expression look something like this: case when (_days_between(current_date, create_date)-no of holidays) between x1 and x2 then count(valueofone) else null end
    Note: My calendar table has a column 'Business Day' which assigns 'Y' to Business day and 'N' to holiday.
    Any help with this expression or any suitable way.
    Regards
    Chilla

    If you have a calendar table, wouldn't your function be just
    CREATE FUNCTION business_days_between( p_day1 IN DATE, p_day2 IN DATE )
      RETURN NUMBER
    IS
      l_cnt NUMBER;
    BEGIN
      SELECT COUNT(*)
        INTO l_cnt
        FROM calendar_table ct
       WHERE ct.business_day = 'Y'
         AND ct.<<date column>> >= trunc(p_day1)
         AND ct.<<date column>> < trunc(p_day2);
      RETURN l_cnt;
    END;Basially, count the number of rows in your calendar table that are business days between the two dates.
    Justin

  • 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

    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

  • Fucntion to Calculate business days (exclude weekends & holidays) between two days

    Hello,
    I need to be able to calculate business days between two dates excluding weekends and holidays. I do have a date dimension and also flags which denote weekday, holiday. Would really appreciate help in building a udf for the business days calculation.
    Thanks,

    Hi, Please take a look and tweak accordingly. Best of luck.
    --Assuming data dimension table something like the following
    --tblDateDim (DT date primary key,
    flagHoliday bit,
    flagWeekday bit
    CREATE FUNCTION fnBusinessDays (
    @StartDate DATE,
    @EndDate DATE
    RETURNS INT
    AS
    BEGIN
    DECLARE @Days INT ;
    SELECT @Days = count(*)
    FROM tblDateDim --// date dimension
    WHERE
    ( DT BETWEEN @StartDate AND @EndDate) --// dt is date column in the table.
    AND --// also flags which denote weekday, holiday
    flagHoliday = 0 --// flagHoliday= 1--Holiday;= 0 --workingday/businessday
    AND
    flagWeekday = 1 --// FlagWeekday = 1--businessday ; =0 --weekend (Saturday and Sunday)
    RETURN (@Days)
    END
    GO

  • Working/Business Days with TimeStampDiff

    Hi,
    Background: I have an order table with a set of possible statuses. There also exists an audit trail that has a timestamp for when a certain status is set.
    Customer wants to measure between two different statuses - which is no problem with a timestampdiff between the two. However, there is also a need to subtract any day classified as a non-business day that falls between the two dates. What i've created is a table that contains the dates that are non-business days. In SQL, i would do this by doing the timestampdiff, then subtracting the count of days that falls between the two dates in the timestampdiff.
    The problem comes when i try to express this in the business model... I can of course do the timestampdiff, but i cannot seem to find a way to do the count of the days in the exception table. Anyone have an idea of how to solve this?

    The easiest way that i can think of is to have a database function created within the database which would accept the 2 dates as parameters and would return the count. Use EVALUATE to call the database function. Use my blog entry here http://oraclebizint.wordpress.com/2007/09/10/oracle-bi-ee-10133-support-for-native-database-functions-and-aggregates/ which would give you a basic idea of calling the database functions.
    Thanks,
    Venkat
    http://oraclebizint.wordpress.com

  • Calculating hours in numerical formats between 2 business days, calculated column

    Hi there,
    I need to calculate how many hours are between 2 days only including business days, outputting in numerical format (ex. 7.3). 
    I've been using this formula to output how many weekdays are between 2 days.
    =IF(AND((WEEKDAY(CompletedTimeStamp,2))<(WEEKDAY(,2)),((WEEKDAY(Created,2))-(WEEKDAY(CompletedTimeStamp,2)))>1),(((DATEDIF(Created,CompletedTimeStamp,"D")+1))-(FLOOR((DATEDIF(Created,CompletedTimeStamp,"D")+1)/7,1)*2)-2),(((DATEDIF(Created,CompletedTimeStamp,"D")+1))-(FLOOR((DATEDIF(Created,CompletedTimeStamp,"D")+1)/7,1)*2)))
    The problem with this is if the 2 dates are on the same day, it outputs "1". I need it to output the amount of hours then / by 24 to give me ".7"  instead.
    Is there anything I can do to convert this current formula to give me hours instead of days?
    Thanks,
    Terence

    The DATEDIF is rounding to the nearest day.
    Try this:
    =IF(AND((WEEKDAY(CompletedTimeStamp,2))<(WEEKDAY(,2)),((WEEKDAY(Created,2))-(WEEKDAY(CompletedTimeStamp,2)))>1),(((CompletedTimeStamp-Created+1))-(FLOOR((CompletedTimeStamp-Created+1)/7,1)*2)-2),(((CompletedTimeStamp-Created+1))-(FLOOR((CompletedTimeStamp-Created+1)/7,1)*2)))
    -1
    Then above will return fractions of days, i.e.  5.5 days. Multiply this by 24 for hours.
    I think there is a extra "+1" in the above example somewhere, so I added a minus 1 to get back the correct value.
    Hi.. Mike.. I am trying to use this calcuation.. its renndering "time being used 3.3".. I need it to calcuate a work day as 8 hrs  so if
    Start Date= 9/12/2014 9:00am
    End Date= 9/16/2014 5:00 pm
    should be 3 (8 hr work days)  any way I can fix this?
    Thanks in advance for your help.
    Mike Smith TechTrainingNotes.blogspot.com

  • "Onsite Next Business Day Warranty" - Current Warranty Request/Warranty Issues/Poor Service

    TL;DR at the bottom of the post, detailed information in between.   I have had a T430s for a little less than three years.  I have called the warranty/customer service ~5+ times and every time gotten extremely poor service, whether it be because parts were "backordered" for weeks at a time, or because "Next Business Day" service has been anything but. I have decided to take a different route for my most recent warranty request, I will keep an up to date account of my request via this forum, with the intent of informing as many as possible with the current state of "Onsite Next Business Day Warranty". I called the warranty ~1hr ago and filed a service request.  The outcome of the request was that "I should receive a call in the next day or so, no later than 5:30PM tomorrow" when the employee I spoke with arrives in the office.  I pressed as to who would call, the employee would not answer definitively, but hinted that it would be his manager, because my warranty request apparently contained "so many parts that it required approval".  The parts have not been shipped, and it was abundantly clear that the subject of the call would be whether this warranty request would get approved. Hopefully, readers can already tell where this is going, next business day onsite repair apparently means in the next 24 hours, you will receive a phone call letting you know if Lenovo will honor their warranty obligations that have already been paid for. To detail my issues:1. The fingerprint scanner has stopped working for the second time. 2. I have had an issue where when I pick up the laptop on the lefthand side, the screen turns to 'snow' and will not return to its regular condition until next boot.  The laptop is unusable in this condition.  I have been attempting to get this fixed essentially since I purchased the laptop, however, after 3 technicians came to 'fix' the issue, it has not been solved.  I have asked/suggested every time I have called the warranty line that the issue is the system board, and it needs to be replaced.  Every time, they have refused to replace the system board, instead opting for other parts, some of which were on 'backorder' for over a month (remember, "Next Business Day Onsite Repair").  The difficulty in obtaining warranty service from Lenovo has caused me to only attempt to get this fixed when other issues pop up, as they have in this case.  Frankly, this issue alone should have caused Lenovo to call this laptop what it is after warranty request #2, a lemon, and they should have/should send a replacement model. 3. The laptop will not 'awake' from sleep mode - when the lid is closed, the keyboard/power button will not respond, and all power sources (battery, charger cable) must be removed and the laptop restarted. 4.  When the laptop is booted up, there is a 'CMOS' error message - I have never had a BIOS battery 'go' in this short a time frame. Issues 1,3, and 4 have cropped up in the last week. The warranty employee suggested that I might need to send my laptop in for 'Depot' repair instead of onsite, which in this instance will not work because of the significant delay that may entail.  I have a professional licensing/certification exam this month, and would greatly prefer that my laptop be in tip-top shape for the exam.  The need to have the greatest level of uptime is what caused me to pay for the NBD Onsite Warranty in the first place. My previous (horrible) warranty experiences and requirement for expedient repair have led me to seek a better method for resolving issues, namely airing them in a public forum, which hopefully will elicit a response from someone who can actually get things done in the warranty department. I have 0 hope of receiving next business day repair (or even repair by Friday, as the warranty explictly says calls received after 4:00 PM might take 2 business days).  I am skeptical that the issue will be resolved in the next week or two. Likewise, I have little hope that [some of] the problem(s) will actually get resolved after "repair" has been made, as historically that has not been the case for me with this laptop.  I will be voting with my dollars after this, as I have been uniformly unimpressed with Lenovo customer service/warranty/etc.  The laptop has been very nice when it doesn't have issues (and when I don't forget to grab it in a certain way), however, everything else about Lenovo has been exceedingly frustrating. The TL;DR of this is:1. If you work for Lenovo and can help, or if you don't and can help, please do!!!  I will be extremely grateful for any assistance. 2. DO NOT under any circumstances purchase the Onsite NBD warranty thinking that the warranty will live up to the title.  I have never received NBD Onsite warranty service, despite repeatedly 'giving' the option to Lenovo to provide such service. 3. If you are considering purchasing a Lenovo product, please read some of the stories people have on their dealings with the support side of the business.  I will speak for myself and say that I will almost certainly never buy another Lenovo product again, and will strongly encourage everyone I know to do the same - after recounting my issues with them.  

    Hey burgerbone,
    Sorry to hear about your troubles getting your machine issues resolved. I am not sure of the onsite policy related to your symptoms but I will be happy to look into it for you.
    Do you mind sending me a PM (Private Message) with your machine/case info?
    Thanks!
    Ty

  • Subtract business days from date - calculated column

    Hello,
    I had a calculated column on a library that took two dates and found the difference between them in business days, but I am not sure how to subtract business days from a date...for instance I get a start date from a form and I need to
    subtract 10 business days from that date.
    Can anyone help?

    I've always resorted to Javascript/JQuery for that kind of function. I found an old fashioned loop worked the best for me - it supports going forward or backwards. I key it off of a change in a starting date, or sometimes a status change. My actual production
    code takes into account another list where we remove holidays and non-work days.
    newDate = getNextDate(newDate, -3);
    $("input[title='Date Due']").val((newDate.getMonth() + 1) + "/" + newDate.getDate() + "/" + newDate.getFullYear());
    function getNextDate(currentDate, offset) {
    // offset is business days
    var wkend = 0;
    var index = Math.abs(offset); // need positive number for looping
    var neg = true;
    if(offset >= 0) { neg = false; }
    var curDOW = currentDate.getDay();
    var nextDate = new Date(currentDate);
    for(var i=1; i <= index; i++) {
    nextDate.setDate(nextDate.getDate() + (neg ? -1: 1));
    var nextDOW = nextDate.getDay();
    if(nextDOW == 0) {nextDate.setDate(nextDate.getDate() + (neg ? -2: 1));} // Sunday
    if(nextDOW == 6) {nextDate.setDate(nextDate.getDate() + (neg ? -1: 2)); } // Sat
    // alert("offset is " + offset + "start: " + currentDate + ", next date is " + nextDate);
    return nextDate;
    Robin

  • Calculate business day between two dates

    Hi Guys
    I need the count of business days between two  dates
    Date1, Date2 i need the count only business day (exclude sartuday&sunday)
    If date1 is null or nothing i need to pass 0
    If date2 is null or nothing i need to pass 0
    help on this

    Hi,
    To achive this within SSRS, go to the report code window and add the below
    Function getBusinessDaysCount(ByVal tFrom As Date, ByVal tTo As Date) As Integer
    Dim tCount As Integer
    Dim tProcessDate As Date = tFrom
    For x as Integer= 1 To DateDiff(DateInterval.Day, tFrom, tTo) + 1
    If Not (tProcessDate.DayOfWeek = DayOfWeek.Saturday Or tProcessDate.DayOfWeek = DayOfWeek.Sunday) Then
    tCount = tCount + 1
    End If
    tProcessDate = DateAdd(DateInterval.Day, 1, tProcessDate)
    Next
    Return tCount
    End Function
    In the textbox where you need to display the value, add the below expression
    =Code.getBusinessDaysCount(parameters!StartDate.Value,parameters!EndDate.Value)
    It is assumed the you want to pass the two days from parameters named Startdate and EndDate. If not, modify the expression with required values.
    Regards
    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH

  • 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:07

    Hi,
    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, Matt

    I 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

  • 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,
    Pradeep

    Hello 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.
    Max

    you 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

Maybe you are looking for

  • Create Credit Memo referenced to Billing Document - Condition Types

    Hello, I need help on this particular situation, your help would be greatly appriciated. I try to create a Credit Memo(VA01) with reference to the Billing Document, but I don't want to see on my Credit Memo a particular Condition Type from the Billin

  • Screenshot problem in Captivate 3/XP

    Greetings, Captivate 3 WinXP, SP3 I'm having trouble getting Captivate to consistently execute a screenshot. Sometimes it works, and sometimes it does not. Most recently it did not work once a dropdown menu was activated from a menu bar. Furthermore,

  • XML/EDL/AAF Issues out of Premiere Pro CS6

    My project (Converted GH2 footage) refuses to export an XML/EDL/AAF. Something has got corrupted or screwed up somewhere. I tested an XML with a new project, with some of the same media files and it exported XML fine. I tried it with Blackmagic Foota

  • There is no option to update my phone to ios 7

    The option to update to ios 7 was there all day but i wasnt home so i didnt have wifi to do it. Now i have wifi and the option isnt there anymore. I even tried turning off my wifi and a view times an error came up but now its back to nothing at all.

  • CSV report download contains "-" for every NULL

    I try to download a report as a CSV file. In every field that contains NULL I get a minus sign ("-"). Is it possible to alter this behaviour so that it returns empty strings ("")?