DateMath Transform not working as expected

Hi All,

I have created a transform which checks the user’s end date and adds 30 days to it. If current date is less than or equal to the calculated value then the user termination status is NO else it will be YES.
Below is the transform for reference.

This transform works fine with all end dates except if the end date value is “9999-12-31”. In this case the transform is throwing an error : “There was an exception while calculating the value for this attribute. null”. Is there any limitation for the dateMath or dateCompare transform?

{
    "id": "ce0cc847-96aa-4090-9d0f-8a8c51e6e6db",
    "name": "30DayTerminationCheck_v2",
    "type": "dateCompare",
    "attributes": {
        "firstDate": "now",
        "secondDate": {
            "type": "dateFormat",
            "attributes": {
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "ISO8601",
                "input": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "input": {
                                    "type": "identityAttribute",
                                    "attributes": {
                                        "name": "endDate"
                                    }
                                },
                                "inputFormat": "yyyy-MM-dd",
                                "outputFormat": "ISO8601"
                            },
                            "type": "dateFormat"
                        },
                        "expression": "+30d/d",
                        "roundUp": true
                    },
                    "type": "dateMath"
                }
            }
        },
        "operator": "lte",
        "positiveCondition": "NO",
        "negativeCondition": "YES"
    },
    "internal": false
}

Thank you

The output of dateMath transform is often assumed to be ISO8601 but it’s actually “yyyy-MM-dd’T’HH:mm”.

Please try changing the format in your transform above. Hope that resolves your issue.

Thanks for the response @sharvari.

But if I change the format from ISO8601 to the one mentioned above, it throws error for all cases(9999-12-31 as well for other end dats). Since, * All dates must be in ISO8601 format in order for the date compare transform to evaluate properly. And I am applying datecompare transform finally.

I think that the dateMath is unable to add 30 days when the end date is 9999-12-31.

When you add 30 days to year 9999-12-31 what it will become, 10000-01-30 which cannot fit in YYYY format rite.

Yes, that’s right and when i tried changing the date format it worked for the end date condition 9999-12-31. But this will fail for other dates.

Seems like we need to make some adjustment to work this out. Thank you @MVKR7T

@anujoseIC I replicated this,

When you add 30 days to 9999-12-31, output will be +10000-01-31T00:00Z

When you add 30 days to 9998-12-31, output will be 9999-01-31T00:00Z

When I tested your transform I can see this error: There was an exception while calculating the value for this attribute. null

Build Transform as follows,

  1. Use conditional Transform
  2. Get end date
  3. if $endDate eq 9999-12-31
  4. Positive condition: no need to add 30 days, in fact you can ignore this user, directly say NO
  5. Negative condition, build the date compare transform

Thanks
Krish

I have modified the transform. And the below one is working for all scenarios.

Thanks all for the help

{
    "id": "ce0cc847-96aa-4090-9d0f-8a8c51e6e6db",
    "name": "30DayTerminationCheck_v2",
    "type": "dateCompare",
    "attributes": {
        "firstDate": "now",
        "secondDate": {
            "type": "dateFormat",
            "attributes": {
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "ISO8601",
                "input": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "input": {
                                    "attributes": {
                                        "endDate": {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "endDate"
                                            }
                                        },
                                        "value": "#if($endDate.contains(\"9999-12\"))9998-12-31#else$endDate#end"
                                    },
                                    "type": "static"
                                },
                                "inputFormat": "yyyy-MM-dd",
                                "outputFormat": "ISO8601"
                            },
                            "type": "dateFormat"
                        },
                        "expression": "+30d/d",
                        "roundUp": "false"
                    },
                    "type": "dateMath"
                }
            }
        },
        "operator": "lte",
        "positiveCondition": "NO",
        "negativeCondition": "YES"
    },
    "internal": false
}

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