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

Similar Messages

  • Calculate Working Days between Two Dates

    Hi All,
    I'm creating a crystal report where I have to calculate the Number of Working Days between a date range, this should exclude the Weekends(done) but also exclude the public holidays which have defined in Holidays Calender.
    I'm not using procedure or command, Operating directly with tables.
    Any help would be appreciated.
    Regards
    Edited by: Pari Minhas on Nov 24, 2011 12:00 AM

    Hi All,
    I'm creating a crystal report where I have to calculate the Number of Working Days between a date range, this should exclude the Weekends(done) but also exclude the public holidays which have defined in Holidays Calender.
    I'm not using procedure or command, Operating directly with tables.
    Any help would be appreciated.
    Regards
    Edited by: Pari Minhas on Nov 24, 2011 12:00 AM

  • Working days between two date fields and Changing Factory Calendar

    Hi,
    I have to calculate working days between two date fields excluding the weekends and public holidays for Switzerland.
    I have written the routine using factory calender and its working fine except for two problems now:
    1. If any one of the date field is empty then teh rsult should be zero.
    2. And the below code is working from 1996 but my cleints wants it to work for years before 1996 as well.
    I also tried to change the Start date in SCAL for factory calendar but it says enter values between 1995 to 2020.
    I am new to ABAP. Please help me how i can achieve these for below code.
    DATA: IT_HOLIDAYS type TABLE OF ISCAL_DAY,
          IS_HOLIDAYS TYPE ISCAL_DAY.
    DATA: T_DATE TYPE SY-DATUM,
          P_DATE TYPE SY-DATUM.
    DATA : X_DATE(4) TYPE C.
    DATA: CNT TYPE I.
    REFRESH : IT_HOLIDAYS.
    CLEAR : IT_HOLIDAYS.
    T_DATE = SOURCE_FIELDS-/BIC/ZCCCHP812.
    P_DATE = SOURCE_FIELDS-/BIC/ZCCCHP810.
    CALL FUNCTION 'HOLIDAY_GET'
    EXPORTING
    HOLIDAY_CALENDAR = 'CH'
    FACTORY_CALENDAR = 'CH'
    DATE_FROM = P_DATE
    DATE_TO   = T_DATE
    TABLES
    HOLIDAYS = IT_HOLIDAYS
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND = 1
    HOLIDAY_CALENDAR_NOT_FOUND = 2
    DATE_HAS_INVALID_FORMAT = 3
    DATE_INCONSISTENCY = 4
    OTHERS = 5.
    DESCRIBE TABLE IT_HOLIDAYS LINES CNT.
    X_DATE = T_DATE - P_DATE - CNT.
    RESULT = X_DATE.
    Please help
    Regards
    Zabina
    Edited by: Syed786 on Nov 2, 2011 9:15 AM

    Hi Zabina,
    Try this function module  'DURATION_DETERMINE'.
    Give the factory calendar and unit as DAY
    With regards,
    Rajesh

  • Calculate Difference in Days Between two Dates

    Hi,
    I'm trying to figure out how to calculate the difference in days between two dates using JavaScript in LiveCycle. (JavaScript knowledge = minimal)
    Where "Start_Date" and "Current_Date" are the names of the two dates in the Hierarchy palette. (both Date/Time Field)
    *Current date is using the Object > Value > Runtime Property > Current Date/Time
    I need a Text or Numeric field displaying the difference in days. (Difference_in_Days)
    I've noticed the following code being pretty standard amongst other responses:
    var 
    Start_Date = new Date(Start_Date);
    var 
    Current_Date = new Date(Current_Date);
    var 
    nAgeMilliseconds = Current_Date.getTime() - Start_Date.getTime();
    var 
    nMilliSecondsPerYear = 365 * 24 * 60 * 60 * 1000;
    I know there's code missing, and the above code might not be correct.
    Please advise.

    Where "DateField01" = user entered date field
    Where "DateFiled02" = Current Date/Time (Runtime Property)
    where "Subform" = the subform containing DateField01
    My script now resembles:
    var oneDay = 24*60*60*1000;
    var firstDate = new Date(Subform.DateField01.rawValue);
    var secondDate = new Date(DateField02.rawValue);  
    (firstDate.getTime() - secondDate.getTime()) / oneDay;
    I tried adding:
    app.alert(String(diffDays));
    Although I assume the reason I didn't get an error is because DateField01 is empty when the form is opened.
    If I swap in actual dates instead of fields it works perfectly.
    When I use the fields I have no information populating after I enter a date in "DateField01"

  • How can I calculate the maximum number of days between two dates in a range of dates?

    I have a column of dates spanning the couse of a few months.  I would like to know if I can calculate the maximum number of days between each row and display the highest number.  I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
    Is this possible?  Any help or suggestions are appreciated.
    Thank you,
    Trevor

    This sounds totally possible,  Can you post a screen shot of your table to make responding more focused?  If you mean you want to:
    A) compute the difference (in days) between two date in the same row, then
    B) find the max duration (in days)
    Here is my take on this problem:
    D2 = C2-B2
    select D2 and fill down
    F1=MAX(D)
    to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image

  • I wanted to know how do you calculate the number of days between two dates

    i wanted to know how do you calculate the number of days between two dates in java ? i get both the dates from the database. i guess there are many issues like leap year and Febuary having diff no of months ..etc.

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

  • How to calculate days between two DATES

    How to calculate days between two DATES ?
    which is the functional module for that ?
    help me

    Hi,
    use function module : it works,
    HR_HK_DIFF_BT_2_DATES
    give output format = 03 and get the value in days.
    code is as below :
    data : DATE1 type P0001-BEGDA,
    DATE2 type P0001-BEGDA,
    YEARS type P0347-SCRYY,
    MONTHS type P0347-SCRMM,
    DAYS type P0347-SCRDD.
    date1 = '20070331'.
    date2 = '20070101'.
    CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
    EXPORTING
    DATE1 = date1
    DATE2 = date2
    OUTPUT_FORMAT = '03'
    IMPORTING
    YEARS = years
    MONTHS = months
    DAYS = days
    EXCEPTIONS
    INVALID_DATES_SPECIFIED = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    write : days.
    Reward points, if helpful,
    Regards,
    Sandeep Kaushik

  • Calculate the Difference Between two dates excluding weekends and Holidays

    Hi,
    We need to calculate the difference between the two dates by excluding the Local public holidays (It is global and varies across countries) and weekends should not be included in calculation for a business day in OBIEE.
    We have two dates: Open date and close date when ever close date is null we are calculating age based on taking the current timestamp and need to exclude the weekends and Holidays when ever the close date is null.
    Ex:
    Col1 col2 Total
    11/9/2010 2:46:38 PM Null 13
    11/2/2010 8:06:26 PM 11/3/2010 5:37:03 PM 1
    (In the Total we shouldn't include the weekends,holidays)
    Please let me know how to calculate the difference between two dates by excluding the weekends and holidays.
    Thanks
    Edited by: user10441472 on Nov 22, 2010 3:14 PM

    You already asked this question and I answered it...
    Re: calculation of Business day in OBIEE

  • How to query the number of working days between two dates

    I'm looking for a solution to calculate the number of <i>working</i> days between two dates that I can use in a formated search. 
    Calculating the total number of days is pretty straight forward but does anyone know how to take into account the settings in the HLD1 (Holiday Dates) table?

    Hi Eric,
    If you are purely looking to exclude holidays defined in the HLD1 table, then you should be able to do it with the following query
    NOTE: The following query is an example using OINV table and the fields DOCDATE and DOCDUEDATE for a Particular DOCNUM  'xxx'
    If you planning to use within the SAP module then replace DOCDATE and DOCDUEDATE with dynamic field references $[$x.x.x]
    SELECT DATEDIFF(DAY,T0.DOCDATE,T0.DOCDUEDATE)-
    (SELECT COUNT(STRDATE) FROM HLD1 WHERE STRDATE >= T0.DOCDATE AND STRDATE <= T0.DOCDUEDATE)
    FROM OINV T0
    WHERE T0.DOCNUM = xxx
    Best Wishes
    Suda

  • Find Exact number of days between two dates

    How can get the exact number of days between two dates?

    An example of business days calculation in SQL */
    /* The algorythm is: */
    /* 1) Take the absolute difference between the dates */
    /* to_date('&todate') - to_date('&frdate') */
    /* 2) Subtract the weekends (number of weeks in the range */
    /* TRUNC(to_date('&todate'),'D') = 1st day of week that */
    /* end of period is in */
    /* TRUNC(to_date('&frdate'),'D') = Last day of week that */
    /* start of period is in */
    /* So subtracting these two gives the number of days */
    /* between the two dates but including all of the days in */
    /* the weeks that the dates start and end in. When this */
    /* number is divided by 7 it gives the number of weeks. */
    /* Multiplying by 2 gives the number of weekend days.     */
    /* 3) Subtract 1 day if the ending date is on a saturday */
    /* DECODE(to_char(to_date('&todate'),'D'),7,-1,0) */
    /* --> If the day of the week is saturday (7), returns -1 */
    /* 4) Subtract 1 day if the start date is on a sunday */
    /* DECODE(to_char(to_date('&frdate'),'D'),1,-1) */
    /* --> If the day of the week is sunday (1), returns 1 */
    /* 5) Add one day to make the range inclusive (The '1 + ' ) */
    /* Author: Kenneth Atkins ([email protected]) */
    /* http://www.olywa.net/katkins/oratip */
    define frdate = '&1'
    define todate = '&2'
    set verify off
    select      
         '&frdate' From_Date
         ,'&todate' To_Date,
         1 + to_date('&todate') - to_date('&frdate') -
         ((TRUNC(to_date('&todate'),'D') - TRUNC(to_date('&frdate'),'D'))/7)*2
         + DECODE(to_char(to_date('&todate'),'D'),7,-1,0)
    + DECODE(to_char(to_date('&frdate'),'D'),1,-1,0) Business_Days
    from dual
    Here is an example of running the script:
    SQL> @busdays 01-AUG-96 15-AUG-96
    FROM_DATE TO_DATE BUSINESS_DAYS
    01-AUG-96 15-AUG-96 11

  • Calculate the difference between two dates

    I would like to calculate the difference between two dates in PL/SQL and return the result as a number of days expressed as an integer value.

    Denes,
    A fair point, I should really have posted this on the SQL forum (I'm new to the forum as well as PL/SQL) but thanks for responding anyway. It does raise a question as to how to implement this in ApEx though.
    I have created the function and am calling it as shown below from the source window of a form. The source type is 'PL/SQL expression or function' and the expression in the source window of the form is:
    calc_date_difference (:p26_c_payment, :p26_c_rec)
    The two parameters being passed are of type date but I'm not sure how to handle the ruturned number and populate the form in ApEx with this value.
    Is it possible to do it this way or am I taking completely the wrong approach?
    Regards
    Sandy
    This is not ApEx related but SQL related:
    CREATE OR REPLACE FUNCTION calc_date_difference (
    p_date_1   VARCHAR2,
    p_date_2   VARCHAR2
    RETURN NUMBER
    v_difference   NUMBER;
    v_sql_err      VARCHAR2 (4000);
    BEGIN
    v_difference := TRUNC (TO_DATE (p_date_1)) - TRUNC
    (TO_DATE (p_date_2));
    RETURN v_difference;
    CEPTION
    WHEN OTHERS
    THEN
    v_sql_err := SQLERRM || CHR (10) || CHR (10) ||
    SQLCODE;
    ND calc_date_difference;and
    SQL> SELECT calc_date_difference ('23.01.2007',
    '20.01.2007') diff
    2    FROM DUAL;
    DIFF
    3
    Denes Kubicek                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Count days between two dates without weekend

    Hi,
    I need a solution in query or another thread, that returns the count of days between two dates without consider weekend (saturday and sunday) , I have the columns of type Date, and the return need in format of hours in one column hh:mm:ss and days in another column.
    Regards
    Jonas

    Hi and welcome to the forum.
    Keep in mind that you can do a search on this forum.
    Your question has been asked before.
    Some other pointers:
    http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:185012348071

  • How to retrieve day between two dates?

    Hi all,
    Hope doing well,
    sir i am retrieving day between two dates in sql server like this.
    select datediff(day,'2012-10-03 00:00:00.000','2012-10-05 00:00:00.000')
    and getting result that is: 2
    but how this type of query i'll use in oracle?
    thanks,

    Just do minus
    diff := date_variable2-date_variable1;The difference sill be in days.
    If you want just the differences in days (Neglecting time part)
    diff := trunc(date2)-trunc(date1);

  • How can i get number of days between two dates represented by two dates?

    how can i get number of days between two dates represented by two date objects. One is java.sql.Date, the other is java.util.Date?

    tej_222 wrote:
    But how do I do that conversion. from java.sql.date and java.util.date to calender?
    -thanks for the quick response.You may find the following utility code samples useful:
    [http://balusc.blogspot.com/2007/09/calendarutil.html]
    [http://balusc.blogspot.com/2007/09/dateutil.html]
    ganeshmb wrote:
    (date1.getTime() - date2.getTime())/(1000*60*60*24) should do.
    getTime returns millsecond value of date object and the difference divided by no of milliseconds in a day should fetch you the difference in terms of days.This doesn't respect the DST. Use java.util.Calendar.

  • Calculate the difference between two dates times in infopath form 2013

    Hi,
    I have an infopath 2013 form that contains three fields:
    2 date time and the 3rd contains the difference between the two in hours
    how I can make the difference between the two so that the display will be like this:
    Date Time1           08/21/2014           22:00 
    Date Time2           08/22/2014           1:00
    Diff Field                                             3:00

    Hi,
    Please refer to the following article which matches your requirement exactly.
    Calculate the difference between two date picker controls in InfoPath using rules and formulas - no code!
    Please mark it answered, if your problem resolved.

Maybe you are looking for

  • Macbook Pro Doesn't Recognize Samsung TV

    Hi all, I've seen this question in a few other discussions which are still unresolved, but I'm hoping maybe I can get some answers. I've been hooking up my MBP 15" to my Samsung LCD TV (Model: LN32B460) for almost a year. Last night, I connected the

  • Can you make a quicktime movie from a uTube video?

    I can watch a particular UTube video on my computers (iMac, Macbook), but not on my iOS devices ('not available on this platform'). Is there a way to download this video in Quicktime, or .MOV etc. format?  I'd like to be able to share it with those w

  • Problem fetch large number of records

    Hi I want to fetch large number of record from database.and I use secondary index database for improve performance for example my database has 100000 records and query fetch 10000 number of records from this database .I use secondary database as inde

  • Address book capacity or amount of memory per entry

    I am working on a project that would add a shared database of contacts to a variety of handhelds.  After searching this forum and others I can see that the address book capacity seems dependent on the onboard memory.  Can any tell me or direct me to 

  • Uicode Conversion Project - Question on transaction UCCHECK

    Hello, We are about to start an Unicode conversion Project. We have SAP 4.7C & we are going to make it Unicode enabled. In order to plan the ABAP/4 resource requirements precisely, I ran transaction UCCHECK to get the list of the development objects