Compare now value with other Date in Transform rule

Hello,

We are triying to compare two dates using Transform rule. We need evaluate if ‘now <= estartDate’ .The rule works when condition is ‘now < startDate’ but we note that condition is not working when ‘now = estartDate’
The start date in the source doesn’t contain ISO format so it always gives output as now > startdate.

We are using the following code.


{
"attributes": {
    "firstDate": "now",
    "secondDate": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "attributeName": "startDate",
                                "sourceName": "Test IDP"
                            },
                        "type": "accountAttribute"
                        },
                    "inputFormat": "PEOPLE_SOFT",
                    "outputFormat": "ISO8601"
                    },
                "type": "dateFormat"        
            },
    "operator": "lte",
    "positiveCondition": "joiner",
    "negativeCondition": "inactive"
},
"type":"dateCompare",
"id":"Test Detect change Department Transform"
}

Is it necessary change date format to now value?. What is the way to evaluate the condition ‘now = estartDate’?

Thanks in advance

Hey @ismaelmoreno1,

I am asking around internally to see if I can get some insights to your question. Please hang tight and we will circle back shortly with some answers for you.

ismaelmoreno1,

I am not a transforms expert, so please take what I am saying with a grain of salt.

It strikes me that you are comparing a date object with a date-time object. The transform explicitly puts the date from PeopleSoft in a dateFormat. The transform does not specify the format for now, so it could be a date-time. Unless you happen to run the transform at the stroke of midnight, now will always be greater than startdate, even when the days match. That is because startdate has no time-of-day component, while now does.

You may want to look into extracting the date component from now, so that you are comparing just the dates.

Rob

1 Like

Hi routters,

Thanks for your comment. I’ve tried with the following rule, but I get a DateException
error , so, my questions is if it is possible change now object to format mm/dd/yyyy


{
"attributes": {
	"firstDate": {
		"attributes": {
			"input": {
				"attributes": {
					"input": "now",
					"inputFormat": "ISO8601",
					"outputFormat": "PEOPLE_SOFT"
				},
				"type": "dateFormat"
			},
			"inputFormat": "PEOPLE_SOFT",
			"outputFormat": "ISO8601"
		},
		"type": "dateFormat"
	},
    "secondDate": {
		"attributes": {
			"input": {
				"attributes": {
					"attributeName": "startDate",
					"sourceName": "Test IDP"
				},
                "type": "accountAttribute"
            },
			"inputFormat": "PEOPLE_SOFT",
			"outputFormat": "ISO8601"
         },
         "type": "dateFormat"        
    },
    "operator": "lte",
    "positiveCondition": "joiner",
    "negativeCondition": "rule"
},
"type":"dateCompare",
"id":"Test Detect change Department Transform"
}

Thanks in advance

Hi,

Finally, I was able to compare now value with other date using the following transform rule

{
    "attributes": {
        "negativeCondition": "rule",
        "positiveCondition": "joiner",
        "firstDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "input": "",
                                "expression": "now"
                            },
                            "type": "dateMath"
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "PEOPLE_SOFT"
                    },
                    "type": "dateFormat"
                },
                "inputFormat": "PEOPLE_SOFT",
                "outputFormat": "ISO8601"
            },
            "type": "dateFormat"
        },
        "secondDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "attributeName": "startDate",
                        "sourceName": "Test IDP"
                    },
                    "type": "accountAttribute"
                },
                "inputFormat": "PEOPLE_SOFT",
                "outputFormat": "ISO8601"
            },
            "type": "dateFormat"
        },
        "operator": "lte"
    },
    "id": "Test Detect change Department Transform",
    "type": "dateCompare"
}
2 Likes

Hey @ismaelmoreno1, I am happy to hear that you were able to find the solution for this issue. Thanks again for posting and please let us know if you have any questions in the future :slight_smile:

1 Like