dateCompare exact match to todays date

As per documentation we just have following operators IdentityNow Transforms - Date Compare - Compass

  • LT: Strictly less than: firstDate < secondDate
  • LTE: Less than or equal to: firstDate <= secondDate
  • GT: Strictly greater than: firstDate > secondDate
  • GTE: Greater than or equal to: firstDate >= secondDate

How can I check if given source attribute value is exactly matching with today’s date? I want to set user ‘ACTIVE’ if he is set to join today. Note: If user is getting joined in “now-7d”, I’m making it as a 'PRE_HIRED"

{
    "attributes": {
        "firstDate": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "sourceName": "Delimited File",
                                    "attributeName": "HIRE_DATE"
                                },
                                "type": "accountAttribute"
                            },
                            "inputFormat": "ddMMyyyy",
                            "outputFormat": "ISO8601"
                        },
                        "type": "dateFormat"
                    },
                    {
                        "attributes": {
                            "input": "31121999",
                            "inputFormat": "ddMMyyyy",
                            "outputFormat": "ISO8601"
                        },
                        "type": "dateFormat"
                    }
                ]
            },
            "type": "firstValid"
        },
        "secondDate": {
            "type": "dateMath",
            "attributes": {
                "expression": "now",
                "roundUp": true
            }
        },
        "operator": "?", // how to compare exact date here?
        "positiveCondition": "Active",
        "negativeCondition": "Inactive"
    },
    "type": "dateCompare",
    "id": "PRE_HIRED DATE COMPARISON"
}


You could try the conditional transform, which compares two values using the eq operator. Your transform might look like this:

{
    "attributes": {
        "firstDate": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "sourceName": "Delimited File",
                                    "attributeName": "HIRE_DATE"
                                },
                                "type": "accountAttribute"
                            },
                            "inputFormat": "ddMMyyyy",
                            "outputFormat": "ISO8601"
                        },
                        "type": "dateFormat"
                    },
                    {
                        "attributes": {
                            "input": "31121999",
                            "inputFormat": "ddMMyyyy",
                            "outputFormat": "ISO8601"
                        },
                        "type": "dateFormat"
                    }
                ]
            },
            "type": "firstValid"
        },
        "secondDate": {
            "type": "dateMath",
            "attributes": {
                "expression": "now",
                "roundUp": true
            }
        },
        "expression": "$firstDate eq $secondDate",
        "positiveCondition": "Active",
        "negativeCondition": "Inactive"
    },
    "type": "conditional",
    "id": "PRE_HIRED DATE COMPARISON"
}

though I’ve specified dateFormat as “ddMMyyyy” still the dates are evaluating as below and hence comparison is always failing

$firstDate = 2021-09-13T00:00:00.000Z
$secondDate = 2021-09-13T16:16:03.397Z

How can I ignore other part of dates e.g hours, minutes, seconds etc?

got it working

{
    "attributes": {
        "firstDate": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "sourceName": "Delimited File",
                                    "attributeName": "LATEST_HIREDT"
                                },
                                "type": "accountAttribute"
                            },
                            "inputFormat": "ddMMyyyy",
                            "outputFormat": "PEOPLE_SOFT"
                        },
                        "type": "dateFormat"
                    },
                    {
                        "attributes": {
                            "input": "31121999",
                            "inputFormat": "ddMMyyyy",
                            "outputFormat": "PEOPLE_SOFT"
                        },
                        "type": "dateFormat"
                    }
                ]
            },
            "type": "firstValid"
        },
        "secondDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "expression": "now",
                        "roundUp": true
                    },
                    "type": "dateMath"
                },
                "inputFormat": "ddMMyyyy",
                "outputFormat": "PEOPLE_SOFT"
            },
            "type": "dateFormat"
        },
        "expression": "$firstDate eq $secondDate",
        "positiveCondition": "Active",
        "negativeCondition": "Inactive"
    },
    "type": "conditional",
    "id": "PRE_HIRED DATE COMPARISON11"
}
1 Like

To remove the time portion of the date, use a dateMath operation with the expression:
“expression”: “+0d/d”,
This will eliminate the time from the date.

1 Like

To be safe, on your datemath operation, try this expression:
“expression”: “now/d”,

I am referencing the datemath documentation: