Transform issue

Hello everyone,
For below transform i am getting the error “There was an exception while calculating the value for this attribute. Text ‘2023-07-19’ could not be parsed at index 10” , can you please help me to solve this error.

{
“name”: “LCS”,
“type”: “dateCompare”,
“attributes”: {
“firstDate”: {
“attributes”: {
“sourceName”: “Test source”,
“attributeName”: “HIREDATE”
},
“type”: “accountAttribute”
},
“secondDate”: “now”,
“operator”: “lt”,
“positiveCondition”: “prehire”,
“negativeCondition”: “active”
}
}

Hi @Kiran001,

Can you try formatting the date input into ISO format before passing it to the dateCompare transform?

The dateCompare transform recommends that the input should be on ISO8601 format,

And according to the dateFormat transform, ISO format looks like the following,

The updated transform might look like,

{
    "name": "LCS",
    "type": "dateCompare",
    "attributes": {
    "firstDate": {
        "type": "dateFormat",
        "attributes": {
          "input": {
            "attributes": {
              "sourceName": "Test source",
              "attributeName": "HIREDATE"
            },
            "type": "accountAttribute"
          },
          "inputFormat": "yyyy-MM-dd",
          "outputFormat": "ISO8601"
        }
    },
    "secondDate": "now",
    "operator": "lt",
    "positiveCondition": "prehire",
    "negativeCondition": "active"
    }
}

Also I would recommend you to use firstValid if you think there could be accounts without that attribute. In that case the code may look like,

{
    "name": "LCS",
    "type": "dateCompare",
    "attributes": {
    "firstDate": {
        "type": "dateFormat",
        "attributes": {
          "input": {
            "attributes": {
              "values": [
                {
                    "attributes": {
                      "sourceName": "Test source",
                      "attributeName": "HIREDATE"
                    },
                    "type": "accountAttribute"
                },
                "1995-12-31"
              ]
            },
            "type": "firstValid",
        },
          "inputFormat": "yyyy-MM-dd",
          "outputFormat": "ISO8601"
        }
    },
    "secondDate": "now",
    "operator": "lt",
    "positiveCondition": "prehire",
    "negativeCondition": "active"
    }
}

Hope this solves the issue.

1 Like

Just wanted to add that as the firstDate is derived from a yyyy-MM-dd value, it will have 00:00 hrs for the time part. Hence, it is better to roundDown the second date by day as well. This can be done by using dateMath transform where expression will be “now/d” and roundUp false. Then use a dateFormat to conver the output to ISO8601

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.