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

Similar Messages

  • Number of business days (excluding holidays) ?

    Hi All,
    What is the SQL query to find number of business days (excluding holidays) between 2 given dates ?
    List of Holidays will be maintained as a separate table.
    I need a SQL query rather than a stored procedure or function.
    I am using oracle 9i.
    Thanks in advance.

    Does this thread help?
    Need to find number of business days - query pls

  • Calculate number of Business Days

    I need to calculate number of Business Days in BODS. Lets say I have One source table and One Date Dimension table to identify Business Day and need to calculate the no of working days and load in to FACT table (Like in screenshot below)?
    By adding Query transform, I can calculate no of Days, but how to calculate working days between ORDER_RECEIVED_DATE and ORDER_SHIPPED_DATE.
    SQL: select count(*) from DIM_DATE  where DATE between ORDER_RECEIVED_DATE and ORDER_SHIPPED_DATE and HOLIDAY_FLAG='NO'

    Prashanth Chinta,
    I have simulated this Job in my repository and and below are the steps by step implementation.
    Your Dataflow will look like below. It contains the source and Target table with expected results. Hope this is what you are looking for.
    DIM_DATE table contains all the dates in a year and mark each date either Holiday as 'YES' or 'NO'
    Qry_Total_Ship_Days Query Transform
    Qry_Join Query Transform
    Qry_Filter_Holidays Query Transform
    Qry_Cnt_Holidays Query Transform
    Qry_Cnt_Holidays Query Transform (This is to show the groupby columns)
    Qry_Cal_Ship_Days Query Transform

  • Add number of working days

    I have to subtract a number of 'working days' of a date field in my message mapping.
    I wrote a user defined function. I used cal.add(Calendar.DATE, -3); on the instance cal of the class Calendar. It subtracts 3 days, but I have to subtract 3 'working days'.
    Has anyone a suggestion how to achieve this?
    Kind regards
    Frank

    Frank,
        Since you said that there is FM available in R/3 DATE_CHECK_WORKINGDAY. I would suggest you to do RFC Lookup and get the response if it not working day, then subtract 1 from the current day, and again do lookup to check whether its working day or not. Finally if you get the response as Working day, then subtract 3 from the day(not from the current date, instead the subtracted date , in my previous step).
    But  it will not solve your issue. The above I said is an approach. Because, consider the below example.
    Current day is Saturday, you r doing RFC lookup and getting response as not-working day. Hence on subtracting 1 you will get Friday, now again you are doing RFC look up , this time you will get response as working day , immediately you will subtract 3 from friday, Finally you will get the result as tuesday!!!!
    Do you think its correct? Yah sometimes, because while subtracting 3 from friday we have to make sure that thursday & wednesday must not be holiday. I think you got my example, If I'm wrong , please reply me back.
    Hope it clears.
    The above is an approach, its not the solution. If you look its good we have to apply logic to ahieve the result.
    Best Regards,
    raj.

  • 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

  • Add line to type ref to data field - type table

    HI All,
    I have field that is defined as type ref to data ,and the type of it is table with data inside of it lr_data.
    I have the also the table type of lr_data and I want to add additional line to the type ref to data field.
    How can i do that ?
    For example
    TYPES: BEGIN OF bank_list,
             country_key type string,
             bank_key    type string ,
             bank_name   type string,
             bank_city  type string    ,
           END OF bank_list.
    data lt_bank type table of bank_list.
    data lr_data data  ref to data.
    Now lr_datae is  type lt_bank " in _Runtine
    and contain 4 entries .
    I get the lr_data with 4 entries and I want to add new entry to the table.
    How can I do that?
    Thanks,
    Joy
    Edited by: Joy Stpr on Feb 8, 2012 10:05 PM

    Hello Joy,
    You can check this code snippet to get an idea on how to proceed with your requirement:
    CLASS lcl_add_data DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS add_data CHANGING ch_data TYPE REF TO data
                               EXCEPTIONS err_invalid_type.
    ENDCLASS.                    "lcl_add_data DEFINITION
    *       CLASS lcl_add_data IMPLEMENTATION
    CLASS lcl_add_data IMPLEMENTATION.
      METHOD add_data.
        DATA: lo_tabdescr   TYPE REF TO cl_abap_tabledescr,
              lo_strucdescr TYPE REF TO cl_abap_structdescr,
              ls_component  TYPE abap_compdescr.
        FIELD-SYMBOLS: <lt_data>      TYPE STANDARD TABLE,
                       <ls_data>      TYPE any,
                       <lv_fieldval>  TYPE any.
        IF ch_data IS BOUND.
    *     Get the runtime type object
          lo_tabdescr  ?= cl_abap_typedescr=>describe_by_data_ref( ch_data ).
    *     Check  if supplied param is table
          IF lo_tabdescr->type_kind NE cl_abap_typedescr=>typekind_table.
            RAISE err_invalid_type.
          ENDIF.
        ELSE.
          RETURN.
        ENDIF.
        ASSIGN ch_data->* TO <lt_data>. "Dereferencing the data reference
    *   Get the line type of table
        lo_strucdescr ?= lo_tabdescr->get_table_line_type( ).
        DO 2 TIMES.
    *     Add initial line to the table
          APPEND INITIAL LINE TO <lt_data> ASSIGNING <ls_data>.
          CLEAR <ls_data>.
    *     Loop on the fields of the structure & populate them
          LOOP AT lo_strucdescr->components INTO ls_component.
            ASSIGN COMPONENT ls_component-name OF STRUCTURE <ls_data> TO <lv_fieldval>.
            CASE ls_component-name.
              WHen 'COUNTRY_KEY'.
                <lv_fieldval> = `My Country`.
              WHEN 'BANK_KEY'.
                <lv_fieldval> = `123`.
              WHEN 'BANK_NAME'.
                <lv_fieldval> = `My Bank`.
              WHEN 'BANK_CITY'.
                <lv_fieldval> = `My City`.
            ENDCASE.
          ENDLOOP.
        ENDDO.
      ENDMETHOD.                    "add_data
    ENDCLASS.                    "lcl_add_data IMPLEMENTATION
    TYPES:
    BEGIN OF bank_list,
      country_key TYPE string,
      bank_key    TYPE string,
      bank_name   TYPE string,
      bank_city   TYPE string,
    END OF bank_list.
    DATA: lt_bank TYPE STANDARD TABLE OF bank_list,
          lr_data TYPE REF TO data.
    START-OF-SELECTION.
      GET REFERENCE OF lt_bank INTO lr_data. "Get reference
    * Add the data to the data reference
      lcl_add_data=>add_data( CHANGING    ch_data = lr_data
                              EXCEPTIONS  err_invalid_type = 1 ).
    BR,
    Suhas

  • How to add 5 hours to an existing date field in the database

    Have a date field 2013-11-21 00:00:00.000 but need to add 5 hours to it to make it 2013-11-21 05:00:00.000.
    Please how can I do this?
    Mijecarr

    Fantastic...
    DATEADD (hour , 5 , Cast(ActivationDate as datetime) ) worked!!!
    Thank you very much
    Mijecarr

  • How to add a pop-up window when date field is populated?

    Hi All,
    I want a pop-up window to open when termination date is entered on MA-Header tab, how can we achieve this. Is there any settings or script ?
    Thanks,
    Saloni

    HI Saloni ,
    Popup windows are not possible in Sourcing by scripting..I too tried for that requirement.
    POP Up Window Possible?
    Regards,
    Uday

  • 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

  • Calculating Business Days in a Date Range

    I have two questions:
    1. Does anyone know a better formula for calculating business days in totals?
    I am currently using the formula in https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/701a52c3-6b1e-2b10-21b3-a6e101be1a0f
    I tailored to my needs.  However, there are still a lot of manual maintenance every year. 
    2. I have many reports that need the formula.  It is very consuming to update the formula in each report.  Does anyone know a better way to do it? 
    I use Crystal XI. 11.0.0.895.  We do have a Crystal Enterprise server hosted in another department.

    Not sure if this is any simpler but you could save this as a custom function, that way you will have to modify it once a year for the holidays.
    numbervar days;
    datevar date1 := minimum({?My Parameter});
    datevar date2 := maximum({?My Parameter});
    days := DateDiff ("d", date1, date2) -
    DateDiff ("ww", date1, date2, crSaturday) -
    DateDiff ("ww", date1, date2, crSunday);    // this will give you the number of business days
                                                        // (excluding Saturdays and Sundays) for a given date range.
    // then, for each holiday, you can enter lines like this
    if date(2008,01,01) in {?My Parameter} then days := days - 1;
    // The final tally of DAYS should give you the total business days in a date range.
    totext(days,0);
    where {?My Parameter} is the date range.

  • Parameters fields - how to disallow entry of non-valid business days (i.e. Sundays or holidays)

    <p>Hello,  </p><p>I&#39;m new to Crystal Reports and was wondering if anyone can advise on using Parameter Fields and Dates. </p><p>I&#39;m developing a report where users will be prompted to enter an "AS OF" date. Because this report is based on the US Domestic stock market, there is no trading that occurs on holidays and weekends. Is there a way to <u><strong><em>dis-allow</em></strong></u> entry of non-valid business days on Parameter fields (dates)? I&#39;ve worked w/ Parameter fields before, but my knowledge is miniscule in this arena. </p><p>Any suggestions or advice you may have is greatly appreciated! </p><p>-Dan Forney </p>

    Step by step, how did you arrive at seeing this agreement?

  • Add new folder/tab into business partner master data form

    Hi, All
    Please show code example: Add folder/tab "business partner master data" form
    add tab folder into "Accounting" this sub folder "General", "Tax", "Example Folder" <=
    Thank  you
    Mdiaw

    Welcome to the forums; this has been covered in lots of posts here so if you do a search you will find lots of replies:
    e.g
    Re: Adding subFolders under a Main Folder
    or
    Add new tabbed page
    or
    Re: Folder within Folder
    or many other returned by searching for "add folder"

  • Business Day Calculation

    I would like to add x number of business days to a date extracted from Discoverer Plus. How might one do so?

    Hi,
    I think passing v_nextBusinessDate for checking holiday will solve your problem. Please refer bold lines.
    create or replace function getNextBusinessDay(IN_DATE date)
         return date
         is
              v_nextBusinessDate date;
              v_isAHoliday boolean;
         begin
              v_isAHoliday := false;
              v_nextBusinessDate := IN_DATE;
              loop
                   v_isAHoliday := check_holiday(v_nextBusinessDate);
                   if (v_isAHoliday = false)
                   then
                        exit;
                   else
                        v_nextBusinessDate := v_nextBusinessDate+ 1;
                   end if;
              end loop;
              return v_nextBusinessDate ;
         end;

  • Data not submitting when I have a conditional display on a date field

    Hello all,
    Could someone please help me with the following issue?
    I have created an updateable report region with four updateable fields. 3 of the fields store a number values and the fourth stores a date value.
    Each updateable report item has a conditional display, and whether they are displayed or not is controlled by the end user using a radio group (with submit). This provides the user with three options.
    If I remove all conditional displays all data will commit to the database without any problems. If I apply the conditional display to the number fields only, again the data will commit as normal. However, as soon as I add a conditional display to the date field it all goes pair shaped. The data will then cease to commit, with no error message at all. Once I remove the conditional display normal service is resumed.
    I'm certainly an APEX novice at the moment, so I wondered if anyone could shed some light on this.
    Thanks in advance for your help
    Steve

    Stew,
    Basically, I have edited each applicable report field column attributes, via the report attributes tab, and selected a conditional display 'Value of item in Expression 1 = Expression 2' for all of them.
    In the same report region I have created a radiogoup with submit called p51_update_type, specifying three static return values; R, F and S
    Condition e.g.
    *"Expression 1"*
    p51_update_type
    *"Expression 2"*
    S
    All columns display as expected, and commits to the database are normal, that is until I apply a conditional display to the date field (which relates to a table column of type DATE in the database).
    Thanks
    Steve

  • 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)

Maybe you are looking for

  • IChat AV does not work behind firewall even after opening up correct ports

    Hi. I am trying to get my iChat setup so that I can do video and audio. It works fine when my mac is directly plugged into the cable modem. When I plug it into my firewall it will not connect. I have read many online manuals and forums and I have tri

  • What is the process to "force close" a pdf that has opened in a separate browser opened by PeopleSft

    PeopleSoft opens a new browser window to view a report from the application.  When the PeopleSoft session closes, is there a process to force close the PDF as well? Thanks! RMGHRMS Bob

  • Two serial numbers requestet - but I only have one

    Hello, I bought a version of lightroom 5 today and downloaded it. Now I wanted to start the program and it asked for two serial numbers. The actually serial number was sent per Email but it also asked for an older serial number, but this is the first

  • Inspection type 0101 steps

    HI QM Guru. i m doing  0101 inspection type.i m doing this steps. first i maintained  0101 inspection type  and controle key in material master. then i maintain QI01 then created PO. after PO released  i do QI07. but when i  excute  the qi07 does not

  • Account hacked and money deducted

    Someone hacked into my account and money has been stolen from my credit card.  In total they tried to steal €300 but only one transaction for €52 worked before i cancelled the card. Be warned. The really frustrating thing is i cannot ring skype or co