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

Date Comparsion fails

SA-28311

Summary



When running a When Rule with condition: @DateTime.compareDatesByDays(@DateTime.CurrentDate("yyyyMMddTHHmmss.SSS zzz","EST"),@DateTime.CurrentDate("yyyyMMddTHHmmss.SSS zzz","EST"),-1) following exception is returned:

Fail: The first date Aug 25, 2016 4:18:09 PM could not be parsed The second date Aug 25, 2016 4:18:09 PM could not be parsed


Error Messages

The following failure is seen in the tracer log:

The first date 22-Sep-16 10:05:55 AM could not be parsed The second date 22-Sep-16 10:05:55 AM could not be parsed



Steps to Reproduce



Create an Activity with the When condition as follows:

@DateTime.compareDatesByDays(@DateTime.CurrentDate("yyyyMMddTHHmmss.SSS zzz","EST"),@DateTime.CurrentDate("yyyyMMddTHHmmss.SSS zzz","EST"),-1)


Root Cause


Though the output of expression @DateTime.CurrentDate("yyyyMMddTHHmmss.SSS zzz","EST") is a String the output is in a format as follows:

However, the function @DateTime.compareDatesByDays() takes parameter in the following String format which is the Pega format.




An alternative function @DateTime.getCurrentTimeStamp() which does give the current date in following format.

Resolution



Recommended local change was as follows:

@DateTime.compareDatesByDays(@DateTime.getCurrentTimeStamp(),@DateTime.getCurrentTimeStamp(),-1)

Published August 23, 2017 - Updated December 2, 2021

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