Nested Transform with dates Comparison

Hi All,

We’ve a requirement to create a transform where it need to check the end date of a source and if end date is greater than 25 days with the current date, it should return static value as “Active” and if end date is between 5 to 15 days with the current date then it should return static condition as “xyzzActive”, and if end date is between 0 to 7 days with current date then static condition is “abcdActiveetc” else if end date is in past static conidtion is terminated. Could anyone please let me know whether this can be achieved using a transform.

Thank you in Advance
Mane

Hello @Mane1,

This one took a little creativity, it is possible! Using DateMath, DateFormat, DateCompare, and the Static transform you can accomplish what you are looking for. You can use DateMath to take todays date "now" + the number of days you want to check. Then you can use the DateFormat transform on both the generated date and the date coming from your source to use within a date compare.

I wrote up a quick template for you to test out. You will need to replace <accountName>, <sourceName>, and <SimpleDateFormatOfEndDate> with your specific values in your tenant.

{
    "name": "EndDateCompare",
    "type":"static",
    "attributes": {
        "inPast": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type":"dateMath",
                            "attributes": {
                                "expression": "now"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "sourceName": "<sourceName>",
                                "attributeName": "<attributeName>"
                            }
                        },
                        "inputFormat": "<SimpleDateFormatOfEndDate>",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "7DayCheck": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type":"dateMath",
                            "attributes": {
                                "expression": "now+7d"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "sourceName": "<sourceName>",
                                "attributeName": "<attributeName>"
                            }
                        },
                        "inputFormat": "<SimpleDateFormatOfEndDate>",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "15DayCheck": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type":"dateMath",
                            "attributes": {
                                "expression": "now+15d"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "sourceName": "<sourceName>",
                                "attributeName": "<attributeName>"
                            }
                        },
                        "inputFormat": "<SimpleDateFormatOfEndDate>",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "25DayCheck": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type":"dateMath",
                            "attributes": {
                                "expression": "now+25d"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "sourceName": "<sourceName>",
                                "attributeName": "<attributeName>"
                            }
                        },
                        "inputFormat": "<SimpleDateFormatOfEndDate>",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "gt",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "value": "#if($7DayCheck=='true'&&inPast=='false')abcdActiveetc#elseif($15DayCheck=='true'&&inPast=='false')xyzzActive#elseif($25DayCheck=='true'&&inPast=='false')Active#{else}terminated#end"
    }
}
1 Like

Thanks a lot @tyler_mairose

Kind Regards
Mane