Date Math 30 days out

A term date comes in as 8/14/2023 and rather than evaluating for other logic it chooses the evaluation for inactiveDelete. I’m guessing I have the dateMath wrong. I thought it was working previously in other testing. The inactiveDelete is for accounts older than 30 days.

I was thinking it was because the data came in as 08/14/2023, but I tried it as 8/14/2023 with the same result.

We want this to evaluate as false as it isn’t 30 days past the term date and move on to other evaluations with other ifelse statements not shown. Other lifecycle states seem to evaluate appropriatly.

"inactiveDelete": {
            "attributes": {
                "negativeCondition": "no",
                "positiveCondition": "yes",
                "firstDate": "now",
                "operator": "gte",
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "inputFormat": "yyyy-MM-dd",
                        "outputFormat": "ISO8601",
                        "input": {
                            "attributes": {
                                "input": {
                                    "attributes": {
                                        "input": {
                                            "attributes": {
                                                "values": [
                                                    {
                                                        "attributes": {
                                                            "attributeName": "TERMINATION_DATE",
                                                            "sourceName": "TST"
                                                        },
                                                        "type": "accountAttribute"
                                                    },
                                                    {
                                                        "attributes": {
                                                            "value": "12/30/2099"
                                                        },
                                                        "type": "static"
                                                    }
                                                ]
                                            },
                                            "type": "firstValid"
                                        },
                                        "inputFormat": "MM/dd/yyyy",
                                        "outputFormat": "ISO8601"
                                    },
                                    "type": "dateFormat"
                                },
                                "expression": "+30d/d",
                                "roundUp": false
                            },
                            "type": "dateMath"
                        }
                    }
                }
            },
            "type": "dateCompare"
        },
        "value": "#if($inactiveDelete == 'yes')inactiveDelete....

Here under secondDate>dateFormat you have yyyy-MM-dd for inputFormat, but the input is a dateMath transform whose output is in yyyy-MM-dd'T'HH:mm format. This will cause the dateFormat transform to fail and return a null output, and I guess this is causing firstDate to be always gte secondDate

1 Like

thank you! However still seeing issues. Any ideas on why the year would seem to change from 2023 to 0023?

The input date is 8/14/2023

When I create a new transform to try to test the logic I see an output on the secondDate as being: 0023-09-10T00:00:00.000Z

It seems to be dropping the 2023 year and instead showing 0023 for the year.

{
    "name": "test datemath",
    "type": "static",
    "attributes": {
        "requiresPeriodicRefresh": "true",
        "today": "now",
        "secondDate": {
            "type": "dateFormat",
            "attributes": {
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "ISO8601",
                "input": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "input": {
                                    "attributes": {
                                        "values": [
                                            {
                                                "attributes": {
                                                    "attributeName": "TERMINATION_DATE",
                                                    "sourceName": "TST"
                                                },
                                                "type": "accountAttribute"
                                            },
                                            {
                                                "attributes": {
                                                    "value": "12/30/2099"
                                                },
                                                "type": "static"
                                            }
                                        ]
                                    },
                                    "type": "firstValid"
                                },
                                "inputFormat": "MM/dd/yyyy",
                                "outputFormat": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
                            },
                            "type": "dateFormat"
                        },
                        "expression": "+30d/d",
                        "roundUp": true
                    },
                    "type": "dateMath"
                }
            }
        },
        "value": "$secondDate"
    },
    "internal": false
}

This is not doing the date compare, but just getting the data prior to the date compare. Being 0023 for the year would also cause this to always evaluate to be true.

The input datetime value must always be in ISO8601 format for dateMath. So your original transform was good there converting the attribute to ISO8601:

"inputFormat": "MM/dd/yyyy",
"outputFormat": "ISO8601"

Then after that, the output format for the DateMath transform is “yyyy-MM-dd’T’HH:mm”. So the next dateFormat should be

"inputFormat": "yyyy-MM-dd'T'HH:mm",
"outputFormat": "ISO8601",

Refer to Date Math for more details:

1 Like

Looks like we had some bad data coming through. Note to self, triple check data and make sure the source data syntax is locked down.

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