Question
Infosys
IN
Last activity: 17 Jul 2017 7:58 EDT
Difference between days function not working as expected
Hi All,
I'm trying to get the difference between 2 days (excluding weekends using the business calendar ) using the below function. But it giving inconsistent result.
@(Pega-RULES:BusinessCalendar).differenceBetweenDays("20170622","20170628" , true,Calendar)
Calendar- excluding the weekends
timezone-Australia/Sydney
PEGA version: 7.1.6
The above function should return 4.
But I'm getting different answers like 3 or 4 or 5 inconsistently.
Could anyone help me on this.
Thanks in advance
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
PEG
GB
Do you mean that you get inconsistent results (ranging from 3 - 5) when using the exact same inputs?
Or does some of this change (like start/end dates) or the calendar name?
If this is always the same calendar, how many calendar pages do you have for "Calendar"?
Infosys
IN
Do you mean that you get inconsistent results (ranging from 3 - 5) when using the exact same inputs?-- Yes I,m using the same inputs. results are in the range of 3-5 in a frequent time .
If this is always the same calendar, how many calendar pages do you have for "Calendar"?-- I'm using only one calendar instance(Data-Admin-Calendar) where I' taking only business days. Regarding the calendar pages, I didn't understand what you are expecting. Can you tell me clearly.
Thanks
-
Smriti Singh
PEG
GB
You can, say, create a calendar called "Sydney" with a start date of 1/1/2017, which you may wish to define your public holidays for the 2017 rule.
Then you may want to add a second calendars for "Syndey" but with a start date of 1/1/2018 (for next yet). So you would have one calendar (Sydney) with two pages.
Infosys
IN
I have only one calendar page.
As of now I didn't configure any public holidays.
Infosys
IN
Pegasystems Inc.
US
HI Natarajan,
On my Pega 7.1.7 system, I created an example and did a test. See attached two snapshots.
I created an activity which did a "Property-Set". It set
@(Pega-RULES:BusinessCalendar).differenceBetweenDays( "20170628","20170622" , true, pxRequestor.pyCalendar)
to an integer.
After I ran it, I checked return value in the tracer log. It was 4. I did several times and I consistently received the value of 4.
One thing I noticed that if I switched "20170628" and "20170622" (just like in your example), I would get negative number.
In function, "differenceBetweenDays", the firstDate parameter should be the later date.
Can you follow my example to check again?
Let me know if you still get different return values.
Thanks,
Susan
Pegasystems Inc.
US
HI Natarajan,
For your information.
I just tested again the same use case on Pega 7.1.6 system (I noticed that you were using version 7.1.6).
The result I received on Pega 7.1.6 was the same as on Pega 7.1.7. It consistently returned value of 4.
Thanks,
Susan
Pegasystems
US
If you're still getting inconsistent results, take a closer look to see what the time values are defaulting to. When you give just a date, it could make a difference whether the time defaults to zero or to the current time, and if that current time crosses a day boundary according to the time zone, it could make a difference.
Infosys
IN
Hi SusanLiu,
Thanks for your reply.
@(Pega-RULES:BusinessCalendar).differenceBetweenDays("20170717","20170706", true,pxRequestor.pyCalendar)
I'm getting the inconsistent result for the above example. Please find the snapshot for your reference.
Thanks