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 September 22, 2016 - Updated August 23, 2017

Have a question? Get answers now.

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