# Query on Date Compare Transform

**URL:** <https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062>\
**Category:** SHF Discussion and Questions\
**Tags:** identity-security-cloud, transforms\
**Created:** [August 1, 2024, 6:47am UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062 "2024-08-01T06:47:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amrit1897](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amrit1897](https://developer.sailpoint.com/discuss/u/Amrit1897)\
**Post date:** [August 1, 2024, 6:47am UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/1 "2024-08-01T06:47:30Z")

</div>

I need to have a transform where it will compare the date based on hire date from account attribute and a static date. If hire date(firstDate) is less than equal to static date(secondDate) then return yes else return HireDate. If boolean value is yes then return startDate identity attribute.

When it is suppose to return StartDate and startDate identity attribute then it is returning static value from StartDate. Below scenarios would make it clear.

1. If hire date is 06/12/2017 which is smaller than static date 05/28/2021(secondDate) then it will meet this condition #if($isNewStartDate == ‘Yes’)$StartDate.  
Current startDate(identityAttribute) is lets say 2017-08-01 then it should have retain the value and return 2017-08-01 but start date is becoming static value of startDate i.e 2020-05-20.

2. If hire date is empty then output is 2020-05-20. - Expected

3. If hire date is 07/31/2024 then output is 2024-07-31 - Expected

Can anyone please suggest why scenario 1 is not working as expected?

Please find below the transform.

```auto
{
    "name": "StartDate",
    "type": "static",
    "attributes": {
        "StartDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "values": [
                            {
                                "attributes": {
                                    "attributeName": "startDate"
                                },
                                "type": "identityAttribute"
                            },
                            "2020-05-20"
                        ]
                    },
                    "type": "firstValid"
                },
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "yyyy-MM-dd"
            },
            "type": "dateFormat"
        },
        "hireDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "attributeName": "HireDate",
                        "sourceName": "Some Source"
                    },
                    "type": "accountAttribute"
                },
                "inputFormat": "MM/dd/yyyy",
                "outputFormat": "yyyy-MM-dd"
            },
            "type": "dateFormat"
        },
        "isNewStartDate": {
            "attributes": {
                "negativeCondition": "No",
                "positiveCondition": "Yes",
                "firstDate": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "attributeName": "HireDate",
                                            "sourceName": "Some Source"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "06/21/2018"
                                ]
                            },
                            "type": "firstValid"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "secondDate": {
                    "attributes": {
                        "input": "05/28/2021",
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "operator": "lte"
            },
            "type": "dateCompare"
        },
        "value": "#if($isNewStartDate == 'Yes')$StartDate#{else}$hireDate#end"
    },
    "internal": false
}

```

---

<div class="post-metadata">

**Author:** ![shekhardas1825](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/shekhardas1825/32/20889_2.png) [@shekhardas1825](https://developer.sailpoint.com/discuss/u/shekhardas1825)\
**Post date:** [August 1, 2024, 7:17am UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/2 "2024-08-01T07:17:50Z")

</div>

@Amrit1897 try with following, I know it’s wired but it works for me.

```auto
“value”: “#if($isNewStartDate == \"Yes\")$StartDate#{else}$hireDate#end”

```

Regards,  
Shekhar Das

---

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [August 1, 2024, 7:37am UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/3 "2024-08-01T07:37:56Z")

</div>

@Amrit1897 The code works fine for me. Looks like the code you given has some validation issue like invalid Single and Double quotes. I have share the formatted file here.  
[StartDate Transform.json](https://developer.sailpoint.com/discuss/uploads/short-url/zby3f4j8jDgy646q3lMwcJBGmnD.json) (2.9 KB)

Regards,  
Shantha Kumar

---

<div class="post-metadata">

**Author:** ![PhilRawlings1](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/philrawlings1/32/37266_2.png) [@PhilRawlings1](https://developer.sailpoint.com/discuss/u/PhilRawlings1)\
**Post date:** [August 1, 2024, 7:38am UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/4 "2024-08-01T07:38:18Z")

</div>

or possibly it’s that your date format is wrong for the startDate variable:

```auto
    "StartDate": {
      "type": "dateFormat",
      "attributes": {
        "input": {
          "type": "firstValid",
          "attributes": {
            "values": [
              {
                "attributes": {
                  "attributeName": "startDate"
                },
                "type": "identityAttribute"
              },
              "05/20/2020" <= this is MM/dd/yyyy
            ]
          }
        },
        "inputFormat": "dd/MM/yyyy", <= should this be MM/dd/yyyy?
        "outputFormat": "yyyy-MM-dd"
      }
    }

```

Don’t forget to encapsulate your code with ``` so that it formats correctly on here

Phil

---

<div class="post-metadata">

**Author:** ![Amrit1897](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amrit1897](https://developer.sailpoint.com/discuss/u/Amrit1897)\
**Post date:** [August 1, 2024, 8:27am UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/5 "2024-08-01T08:27:33Z")

</div>

Hi Phill, It was mistake while asking. I have updated my ask.

---

<div class="post-metadata">

**Author:** ![neeraj99](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/neeraj99/32/14001_2.png) [@neeraj99](https://developer.sailpoint.com/discuss/u/neeraj99)\
**Post date:** [August 1, 2024, 10:23am UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/6 "2024-08-01T10:23:25Z")

</div>

Hi @Amrit1897 i don’t understand you 1. condition that is when do you want to populate the already present identity attribute date ??

But i do understand that you want to have the existing Identity attribute date also displayed. In that case i will say add few more snippets in the transform for $oldValue and its checks.

I am attaching the sample snippet below.

```auto
"priorValue": {
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "value": "$oldValue"
                },
                "type": "static"
            },
            {
                "attributes": {
                    "value": "N/A"
                },
                "type": "static"
            }
        ]
    }
},
"todayDate": {
    "type": "dateFormat",
    "attributes": {
        "input": {
            "type": "dateMath",
            "attributes": {
                "input": "",
                "expression": "now",
                "roundUp": false
            }
        },
        "inputFormat": "yyyy-MM-dd",
        "outputFormat": "yyyy-MM-dd"
    }
},
"value": "#if($priorValue != 'N/A')$priorValue#else$todayDate#end" //here add additional check for where you require your existing date to be populated what is that condition.

```

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [August 1, 2024, 12:45pm UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/7 "2024-08-01T12:45:55Z")

</div>

> [@Amrit1897](#):
>
> Current startDate(identityAttribute) is lets say 2017-08-01 then it should have retain the value and return 2017-08-01 but start date is becoming static value of startDate i.e 2020-05-20.

Did the identity attribute have the value `2017-08-01` before you started testing the transform? Any values assigned to identity attributes while `preview`ing the transform results are temporary only and will not be available for the next preview. Based on your transform, only reason for you to get the date as ‘2020-05-20’ can be current startDate for the identity is empty

---

<div class="post-metadata">

**Author:** ![Amrit1897](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amrit1897](https://developer.sailpoint.com/discuss/u/Amrit1897)\
**Post date:** [August 1, 2024, 5:43pm UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/8 "2024-08-01T17:43:13Z")

</div>

> [@iamnithesh](#):
>
> 2020-05-20

Yes, 2020-05-20 is coming when startDate is empty.  
But 2020-05-20 is also coming when startDate is 2017-08-01.

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [August 1, 2024, 5:52pm UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/9 "2024-08-01T17:52:31Z")

</div>

okay… here is the issue  
Your transform:  
 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/0/045422eff871604d576a922c635fe1169346b8d3.png)

Correct format:  
 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/6/63a648ff3f56bab9748446da2387a15e1559a225.png)

It’s `"name"`, not `"attributeName"` inside `attributes` block of an Identity Attribute transform

---

<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:** [September 30, 2024, 5:53pm UTC](https://developer.sailpoint.com/discuss/t/query-on-date-compare-transform/75062/10 "2024-09-30T17:53:28Z")

</div>

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