11 Replies Latest reply: May 15, 2014 10:09 AM by elginreigner _ RSS

    Working days

    ChristD _

      I have a problem with the function "_WorkingDays_ComputeNormalWorkingDaysInRange". All calculations are ok except when the start date and the end date are the same; in that case the result is always -1 while it should be zero.

       

      I have probably overlooked a setting within the working days function, but I cannot find the solution in the Monarch help or in this forum.

       

      Any help is appreciated.

       

      Regards,

      Christ

       

      Monarch V10.5

        • Working days
          Data Kruncher

          Have you by chance modified any of the custom _WorkingDays functions?

           

          For me, this calculation returns a value of 1.

          _WorkingDays_ComputeNormalWorkingDaysInRange({2010-10-19},{2010-10-19})[/code]

            • Working days
              ChristD _

              No, I have not changed it.

              I would have expected the result to be zero, not 1.

               

              Regards,

              Christ

                • Working days
                  Olly Bond

                  Hello ChristD,

                   

                  I would have thought that if a range from (Monday,Tuesday) should give you the result of 2, then the range from (Monday,Monday) should return 1? Am I missing something?

                   

                  Best wishes,

                   

                  Olly

                    • Working days
                      ChristD _

                      The issue as Data Kruncher has described it:

                       

                       

                      For me, this calculation returns a value of 1.

                       

                      Code:

                      WorkingDaysComputeNormalWorkingDaysInRange({2010-10-19},{2010-10-19})

                       

                      This returns the value of 1 (day difference) while the result should be zero days difference, because the beginning and end date are exactly the same.

                       

                      Christ

                        • Working days
                          Data Kruncher

                          It's all in how you look at it, I suppose.

                           

                          To my mind, the "NormalWorkingDaysInRange" is one day when the start is the same as the end. To me, it's accurately representing the number of days.

                           

                          But I suspect that your view of it is more along the lines of the "number of elapsed days in range", so when a value of zero for the same start and end dates is more accurate.

                           

                          To get the result that you desire, just deduct one from the result of WorkingDaysComputeNormalWorkingDaysInRange().

                           

                          Still not sure how you got -1 though. :confused:

                           

                          Was the end date prior to the start date maybe?

                            • Working days
                              ChristD _

                              I keep on finding it wierd that when todays date versus yesterdays date results in 1 and todays date versus today also is one, but I have used an if function in this case to set the result to zero if the dates are the same.

                               

                              The -1 was the result because of the specific function I used this for, which in some cases the two dates would not necessarily be consistent that one would be only the start date and the other the end date; so also here I have used an if function which returned the same date as negative. The basic issue was described above and I have to use a work-around to overcome the issue.

                               

                              Thanks for your quick responses.

                               

                              Regards,

                              Christ

                                • Working days
                                  elginreigner _

                                  I think you both are in the same understanding but when you use the following code you get the same results:

                                   

                                  WorkingDaysComputeNormalWorkingDaysInRange({2010-10-19},{2010-10-19})

                                   

                                  or

                                   

                                  WorkingDaysComputeNormalWorkingDaysInRange({2010-10-19},{2010-10-20})

                                   

                                  Monarch returns 1 for both situations. This may be a bug.

                                    • Working days
                                      Data Kruncher

                                      All,

                                       

                                      Now that I've located the definitive answer for this topic, I realize that it should have been more obvious from the start.

                                       

                                      The answer is found in the formula of the custom function Working_Days(). You'll appreciate the commentary in the formula. To view it, edit the formula of the user defined function.

                                       

                                      I won't reproduce it here. Go have a look.

                                        • Working days
                                          elginreigner _

                                          Data

                                           

                                          Are you stating that this function :

                                           

                                          WorkingDaysComputeNormalWorkingDaysInRange(,)

                                           

                                          is dependent on the Workingdays(,) function? Therefore, requiring the setup of the user defined functions?

                                            • Working days
                                              Data Kruncher

                                              Yes, that's correct. EDIT: No, I interpreted that backwards. Read it too quickly. WorkingDays(from,to) depends upon the various _Working functions, which have some inter-dependencies.

                                               

                                              There are a number of user-defined functions that should to be customized to get the desired outputs. The comments attached to each function describe the component functions that need attention. Have a look at the formulas for the various _Working functions.