10 Replies Latest reply on Jul 7, 2016 5:37 PM by Dan Gagnon

    Find the number of days between two dates

    Vicks_

      Hi Guys,

       

      I would like to calculate the number of days between two dates in a planning form including my end date in calculation.

      I wrote a script and which is working fine except FY14-15 March.  03/09/15 it is not considered in the calculation and hence it impacts the whole year calculation. Please find the below with example


      Here I am keeping the start date constant and changing the end date.


      Case 1: (Working Fine)

      Start Date: 11/29/14

      End Date: 03/07/15

      Number of days: 99

       

      Case 2: (Working Fine)

      Start Date: 11/29/14

      End Date: 03/08/15

      Number of days: 100

       

      Case 3: (Ignoring March 9 and still showing the result as 100 instead of 101)

      Start Date: 11/29/14

      End Date: 03/09/15

      Number of days: 100

       

      Case 4: (Ignored March 9 and showing the result as 101 instead of 102)

      Start Date: 11/29/14

      End Date: 03/10/15

      Number of days: 101

       

      Case 5: (Ignored March 9 and showing the result as 102 instead of 103)

      Start Date: 11/29/14

      End Date: 03/11/15

      Number of days: 102

       

      And this one day difference is carried on till the end of the year.


      I tried with the below functions one by one. But got the same result for all these 3 functions.


      "Number of days"=   @CalcMgrdatediff("EndDate","Start date","Day")+1;

      "Number of days"=   @HSPDateDiff("EndDate","Start Date")+1;

      "Number of days"=   @CalcMgrDaysBetween("EndDate","Start Date")+1;


       

      Here while calculating it is ignoring 9th March 2015 from the calendar. What is the magic here. Can someone reveal it?  And while doing testing I randomly found this error. Not sure where else in the calendar it will give this error.

      And also advise me with the correct script to find the number of days between dates in HP Version 11.1.2.4