Need help with Transform

Hello Experts,
All new to this TRansform thing.

I am trying to calculate “startdate+10days”, “todayDate” . This will basically add 10 to the datehired and compare with todayDate.

it should return true if todayDate is less than the “startdate+10days”.
I feel like this operator "<‘’ is not working in this whole transform.



{
    "id": "26578",
    "name": "TransformName",
    "type": "static",
    "attributes": {                  
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        
        "startDatePlusTen": {
            "attributes": {
                "expression": "+10d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "value": "#if($todayDate <= $startDatePlusTen))true#{else}false#end"
    },
    "internal": false
}"```

Hello Rita,
I have updated your code. Please use below transform.

{
    "id": "26578",
    "name": "TransformName",
    "type": "datecompare",
    "attributes": {                  
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        
        "startDatePlusTen": {
            "attributes": {
                "expression": "+10d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
		"operator": "lte",
    "positiveCondition": "true",
    "negativeCondition": "false"
    
    },	
    "internal": false
}

Please let me know if this works.
Santosh

@santupatel2025
Thank you,
It did worked for less than but I am trying to perform this <= comaprison. Also What If i want to add one more attribute like startdate-1.

My question is how can I compare multiple dates with this format

Instead of giving true or false on positive and negative condition create a another compare for the startdate-1, by this way you can achieve it.
LMK if any additional inputs needed.

Hello @Santhakumar I really appreciate your reply. I am able to create the time
I want to compare todayDate(currentDate) with startDate,startDateMinusOne,startDateMinusTwo,startDatePlusTen.
this is the end result I am trying to achieve
#if(($todayDate == $startDate || $todayDate == $startDateMinusTwo || $todayDate == $startDateMinusOne || $todayDate <= $startDatePlusTen))true#{else}false#end"
Could you help me to set up the operator in this transform so I can achieve above result. This is what I have created so far.


{
    "id": "26578",
    "name": "TransformName",
    "type": "datecompare",
    "attributes": {
     "startDate": {
            "attributes": {
                "expression": "+0d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },	
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
		"startDateMinusOne": {
            "attributes": {
                "expression": "-1d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
		"startDateMinusTwo": {
            "attributes": {
                "expression": "-2d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        
        "startDatePlusTen": {
            "attributes": {
                "expression": "+10d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
		"operator": "lte",
    "positiveCondition": "true",
    "negativeCondition": "false"
    
    },	
    "internal": false
} 

Thank you
Best Regards

Can you give me more details on the below condition? Is the below scenario is correct for your case?

  1. todayDate = 2025-01-27
  2. startDate = 2025-01-27
  3. startDateMinusTwo = 2025-01-25
  4. startDateMinusOne = 2025-01-26
  5. startDateMinusTen = 2025-01-17

Let assume the above are the dates for the input of transform. Now the condition you are checking is:
#if(($todayDate == $startDate || $todayDate == $startDateMinusTwo || $todayDate == $startDateMinusOne || $todayDate <= $startDatePlusTen))true#{else}false#end"

Hello @Santhakumar ,

This is absolutely correct.

Thank you
Best Regard

Hello @Santhakumar

I came up with this. But getting null error.

{
    "id": "26578",
    "name": "TransformName",
    "type": "datecompare",
    "attributes": {
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        "startDate": {
            "attributes": {
                "expression": "+0d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "startDateMinusOne": {
            "attributes": {
                "expression": "-1d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "startDateMinusTwo": {
            "attributes": {
                "expression": "-2d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "startDatePlusTen": {
            "attributes": {
                "expression": "+10d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "conditions": [
            {
                "operator": "eq",
                "left": "$todayDate",
                "right": "$startDate"
            },
            {
                "operator": "eq",
                "left": "$todayDate",
                "right": "$startDateMinusTwo"
            },
            {
                "operator": "eq",
                "left": "$todayDate",
                "right": "$startDateMinusOne"
            },
            {
                "operator": "lte",
                "left": "$todayDate",
                "right": "$startDatePlusTen"
            }
        ],
        "combineOperator": "or",
        "positiveCondition": "true",
        "negativeCondition": "false"
    },
    "internal": false
}

For reference transform operation mention only the name of the transform no need to put the full transform. Try the below transform and lmk.

{
    "id": "26578",
    "name": "TransformName",
    "type": "datecompare",
    "attributes": {
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        "startDate": {
            "attributes": {
                "expression": "+0d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO"
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "startDateMinusOne": {
            "attributes": {
                "expression": "-1d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO"
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "startDateMinusTwo": {
            "attributes": {
                "expression": "-2d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO"
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "startDatePlusTen": {
            "attributes": {
                "expression": "+10d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO"
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
        "conditions": [
            {
                "operator": "eq",
                "left": "$todayDate",
                "right": "$startDate"
            },
            {
                "operator": "eq",
                "left": "$todayDate",
                "right": "$startDateMinusTwo"
            },
            {
                "operator": "eq",
                "left": "$todayDate",
                "right": "$startDateMinusOne"
            },
            {
                "operator": "lte",
                "left": "$todayDate",
                "right": "$startDatePlusTen"
            }
        ],
        "combineOperator": "or",
        "positiveCondition": "true",
        "negativeCondition": "false"
    },
    "internal": false
}
1 Like

Hello Rita,
I have updated the transform based on your requirement.

{
    "id": "26578",
    "name": "TransformName",
    "type": "static",
    "attributes": {
	"startDate": {
	"type": "datecompare",
    "attributes": {                  
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        
        "startDate": {
            "attributes": {
                "expression": "+0d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
		"operator": "lt",
    "positiveCondition": "active",
    "negativeCondition": "terminated"
    
    }
	},
	"startDateMinusOne": {
	"type": "datecompare",
    "attributes": {                  
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        
        "startDateMinusOne": {
            "attributes": {
                "expression": "-1d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
		"operator": "lt",
    "positiveCondition": "active",
    "negativeCondition": "terminated"
    
    }},
	"startDateMinusTwo": {
	"type": "datecompare",
    "attributes": {                  
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        
        "startDateMinueTwo": {
            "attributes": {
                "expression": "-2d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
		"operator": "lt",
    "positiveCondition": "active",
    "negativeCondition": "terminated"
    
    }
	},
	"startDatePlusTen": {
	"type": "datecompare",
    "attributes": {                  
        "todayDate": {
            "attributes": {
                "expression": "now/d",
                "roundUp": "false"
            },
            "type": "dateMath"
        },
        
        "startDatePlusTen": {
            "attributes": {
                "expression": "+10d/d",
                "roundUp": "false",
                "input": {
                    "attributes": {
                        "id": "HP-Format_Date_to_ISO",
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "sourceName": "HR",
                                            "attributeName": "DateHired",
                                            
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "5/7/2099"
                                ]
                            },
                            "type": "firstValid"
                        }
                    },
                    "type": "reference"
                }
            },
            "type": "dateMath"
        },
		"operator": "lte",
    "positiveCondition": "active",
    "negativeCondition": "terminated"   
    }
	},
	"value": "#if(('active' == $startDate || 'active' == $startDateMinusTwo || 'active' == $startDateMinusOne || 'active' == $startDatePlusTen))true#{else}false#end"       
    },
    "internal": false
}

Please let me know if it works

Thanks
Santosh

Hello @santupatel2025

I tried the solution but getting this error. Does this mean there is no value coming in?

Hello @Santhakumar

I will need to refer the Source and its attribute otherwise there will be no value to compare. The reference transform doesn’t hold any value just the data format.

Thank you
Rita

Actually the reference operation is used to call another transform so you don’t need to mention. Did you created the transform for the date compare?

Yes, I created datecompare transform

Hi,
I feel that there is a lot wrong with your transform.
dateCompare uses ‘firstDate’ & ‘secondDate’, not bespoke names
i don’t know what this is actually doing, ’
“id”: “HP-Format_Date_to_ISO”,’ but seems overly complicated, when the internal transform ‘dateFormat’ will do the job
there are terminating commas that will cause the code to fail. eg. “attributeName”: “DateHired”,

The transform is very large, and very easy to make mistakes that are hard to spot.
I would suggest building it in stages and creating test.identity.attributes to verify each part of.

I’ve reworked the 1st part for you from:

  "type": "static",
  "attributes": {
    "startDate": {
      "type": "datecompare",
      "attributes": {
        "todayDate": {
          "attributes": {
            "expression": "now/d",
            "roundUp": "false"
          },
          "type": "dateMath"
        },
        "startDate": {
          "attributes": {
            "expression": "+0d/d",
            "roundUp": "false",
            "input": {
              "attributes": {
                "id": "HP-Format_Date_to_ISO",
                "input": {
                  "attributes": {
                    "values": [
                      {
                        "attributes": {
                          "sourceName": "HR",
                          "attributeName": "DateHired",   <=== this comma will cause problems
                        },
                        "type": "accountAttribute"
                      },
                      "5/7/2099"
                    ]
                  },
                  "type": "firstValid"
                }
              },
              "type": "reference"
            }
          },
          "type": "dateMath"
        },
        "operator": "lt",
        "positiveCondition": "active",
        "negativeCondition": "terminated"
      }
    }

to

{
  "startDate": {
    "type": "datecompare",
    "attributes": {
      "firstDate": "now",
      "secondDate": {
        "type": "dateFormat",
        "attributes": {
          "input": {
            "type": "firstValid",
            "attributes": {
              "values": [
                {
                  "type": "accountAttribute",
                  "attributes": {
                    "sourceName": "HR",
                    "attributeName": "DateHired"   ***this
                  }
                },   
                "5/7/2099"                         ***and this must be in the same format
              ]
            }
          }
        },
        "inputFormat": "d/MM/yyyy",                ****must match the input format
        "outputFormat": "ISO8601"
      }
    }
  },
  "operator": "lt",
  "positiveCondition": "active",
  "negativeCondition": "terminated"
}

Hope that makes sense

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