# Date Compare transform

**URL:** <https://developer.sailpoint.com/discuss/t/date-compare-transform/100829>\
**Category:** SHF Discussion and Questions\
**Tags:** identity-security-cloud\
**Created:** [February 12, 2025, 6:45pm UTC](https://developer.sailpoint.com/discuss/t/date-compare-transform/100829 "2025-02-12T18:45:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![j1241](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@j1241](https://developer.sailpoint.com/discuss/u/j1241)\
**Post date:** [February 12, 2025, 6:45pm UTC](https://developer.sailpoint.com/discuss/t/date-compare-transform/100829/1 "2025-02-12T18:45:05Z")

</div>

Hello Experts,  
I have created below DataCompare Transform. But getting the null error

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/f/3/f348c31743a52a76425184466156d897eee79cab.png)

I am comparing ADLastLogOn+50 days with today.

adLastLogon is an Identity Attribute that has been modified to this format  
yyyy-MM-dd

If ADLastLogOn+50 days is less than or equals to today.  
Could anybody tell me what am I doing wrong here?

```auto
{
    "id": "",
    "name": "Test-DateCompare",
    "type": "dateCompare",
    "attributes": {
        "firstDate": {
            "type": "dateMath",
            "attributes": {
                "expression": "+50d",
                "roundUp": false,
                "input": {
                    "type": "dateFormat",
                    "attributes": {
                        "inputFormat": "yyyy-MM-dd",
                        "outputFormat": "ISO8601",
                        "input": {
                            "attributes": {
                                "name": "adLastLogon"
                            },
                            "type": "identityAttribute"
                        }
                    }
                }
            }
        },
        "secondDate": {
            "type": "dateMath",
            "attributes": {
                "expression": "now",
                "roundUp": false
            },
            "operator": "lte",
            "positiveCondition": "yes",
            "negativeCondition": "No"
        }
    },
    "internal": false
}

```

Thank you

---

<div class="post-metadata">

**Author:** ![gourab](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gourab/32/18650_2.png) [@gourab](https://developer.sailpoint.com/discuss/u/gourab)\
**Post date:** [February 12, 2025, 7:05pm UTC](https://developer.sailpoint.com/discuss/t/date-compare-transform/100829/2 "2025-02-12T19:05:34Z")

</div>

Hi @j1241 ,  
I suggest you to :

1. add firstValid Transform to handle any Null values first.
2. Apart from this confirm the date format of the AD attribute that you are using.

As a reference you can follow this transform as example written by @sup3rmark : [Find Latest Date Transform](https://developer.sailpoint.com/discuss/t/find-latest-date-transform/35207)

Hope this Helps!

---

<div class="post-metadata">

**Author:** ![sup3rmark](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sup3rmark/32/36229_2.png) [@sup3rmark](https://developer.sailpoint.com/discuss/u/sup3rmark)\
**Post date:** [February 12, 2025, 7:29pm UTC](https://developer.sailpoint.com/discuss/t/date-compare-transform/100829/3 "2025-02-12T19:29:15Z")

</div>

The primary issue here is that you have your `operator`, `positivecondition`, and `negativeCondition` inside of the `secondDate` object. They should be outside of that, but still within the `attributes` object.

There’s a more general issue of using the `adLastLogon` attribute to determine whether an account is still in-use. As @gourab mentioned, I have shared a transform previously that addresses those issues and should be ready to drop right into any environment using an Active Directory source and an Entra ID source.

---

<div class="post-metadata">

**Author:** ![j1241](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@j1241](https://developer.sailpoint.com/discuss/u/j1241)\
**Post date:** [February 12, 2025, 7:52pm UTC](https://developer.sailpoint.com/discuss/t/date-compare-transform/100829/4 "2025-02-12T19:52:11Z")

</div>

Thank you @sup3rmark and @gourab

I considered both of your suggestion and made it work.

Here is the corrected version:

```auto
{
    "id": "",
    "name": "Test-DateCompare",
    "type": "dateCompare",
    "attributes": {
        "firstDate": {
            "type": "dateMath",
            "attributes": {
                "expression": "+50d",
                "roundUp": false,
                "input": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "firstValid",
                            "attributes": {
                                "values": [
                                    {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "lastLogonTimestamp",
                                            "sourceName": "Active Directory Prod"
                                        }
                                    }
                                ]
                            }
                        },
                        "inputFormat": "EPOCH_TIME_WIN32",
                        "outputFormat": "ISO8601"
                    }
                }
            }
        },
        "secondDate": {
            "type": "dateMath",
            "attributes": {
                "expression": "now",
                "roundUp": false
            }
        },
        "operator": "lte",
        "positiveCondition": "yes",
        "negativeCondition": "no"
    },
    "internal": false
}

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [April 13, 2025, 7:52pm UTC](https://developer.sailpoint.com/discuss/t/date-compare-transform/100829/5 "2025-04-13T19:52:41Z")

</div>

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