Support Article
FormatDateTime function returns incorrect result
Summary
User is using FormatDateTime function to convert date format from GMT to SGD format.
This function is returning incorrect date when run this function by agent or an activty.
.
Error Messages
Incorrect Date Conversion happened
Steps to Reproduce
1) Write an activity to convert GMT time to SGD time format using FormatDateTime function. (print the output in PegaRULES log).
2) Call this activity using agent rule.
3) Run the activity manually.
4) Compare the results.
Note: Manual run provides expected output and agent run provides incorrect results.
Root Cause
User has given incorrect Date Format in the FormatDateTime function resulting in wrong values for some Dates during conversion.
Resolution
Here’s the explanation for the reported behavior:
The function allows only the below highlighted Date /DateTime formats only and they are case sensitive.
In this Case, user is giving it as YYYY-MM-dd which should be given only as yyyyMMdd.
FormatDateTime("20090109T162504.370 GMT", "MMMM dd,yyyy hh:mm:ss a", "America/New_York", "en_US") = "Jan 9, 2009 11:25:04 AM"
FormatDateTime("20090109T162504.370 GMT", HHmmss, "America/New_York", "en_US") = "112504"
FormatDateTime("20090109T162504.370 GMT", "yyyyMMdd", "America/New_York", "en_US") = "20090109"
Published March 17, 2017 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.