Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

DifferenceBetweenDays is calculated incorrectly

SA-26422

Summary



The user is performing "DifferenceBetweenDays" for two dates in "Asia/Colombo" timezone. Differencebetweendays is calculating one day extra than excepted when non-business days are included between the two dates. 
  1. User is in Asia/Colombo time zone executes the report which calculates "DifferenceBetweenDays" on Friday. 
  2. When the same report is executed on Monday, an extra day is given in the result count. 


Error Messages

Incorrectly calculates the difference between two days when non-business days are included. 


Steps to Reproduce



Configure a report which calculates DifferenceBetweenDays for two dates.
User should execute a report on a Friday from Asia/Colombo time zone.
When the same report is executed on Monday, an extra day is given in the result count.

Root Cause



User has configured different timezones for the same operator ID. On opening the operator record, the timezone is "Asia/Colombo" and upon opening the corresponding calendar for the same operator, there the timezone is specified as "America/NewYork"

Resolution



Local Change- Ideally the operator time zone and the calendar used for date time operations must be of same time zone at run time. Else it will result in incorrect results.

The reason the timezone of the calendar which operator uses and operator time zone needs to be same:

In the function DifferenceBetweenDays the input date time Strings are parsed to Date objects so the operator time zone will be used. The difference in days is calculated using the time zone of the business calendar. 

When operator time zone is "America/new york" the input first date(20160418) and second date(20160412) strings will be parsed as Dates whose values are : 
firstDate : Tue Apr 18 09:30:00 IST 2016 
secondDate : Fri Apr 12 09:30:00 IST 2016 

This when set on calendar whose time zone is new york by setting time part to zero's yields below results. 
i.e. 
firstDate : Mon Apr 18 00:00:00 IST 2016 
secondDate : Sun Apr 12 00:00:00 IST 2016 


But when operator time zone is "Asia/Colombo" the input first date(20160418) and second date(20160412) strings will be parsed as Dates whose values are : 
firstDate : Tue Apr 18 00:00:00 IST 2016 
secondDate : Fri Apr 12 00:00:00 IST 2016 

This when set on calendar whose time zone is new york by setting time part to zero's yields below results. 
i.e. 
firstDate : Sun Apr 17 09:30:00 IST 2016 
secondDate : Mon Apr 11 09:30:00 IST 2016 

On the above date, the difference is calculated, the days will be 5. 

So when parsing of date time Strings to Date , the date may actually become 1 day before/after depending on time zone and because of this incorrect results will be seen. 

Please refer to https://pdn.pega.com/sites/default/files/help_v63sp1/Default.htm#data-/data-admin-/data-admin-operator-/data-admin-operator-id/advanced.htm which talks about the calendar and time zone relation for an operator. 

 

 

Published August 6, 2016 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us