Date Comparing Transform

Hello Everyone,

We created a transform that will decided if the UserPass value to be true or false.
It should be true in either of these conditions

[todayDate == $startDate || $todayDate == $startDateMinusTwo || $todayDate == $startDateMinusOne || $todayDate <= $startDatePlusTen]

It working all fine except for “startDatePlusTen”, if someone’s start date is 2025-01-17
it should return true but returning false.

Can anyone please help me what I am doing wrong here?

{
    "id": "12345",
    "name": "User",
    "type": "static",
    "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"
        },
        "value": "#if(($todayDate == $startDate || $todayDate == $startDateMinusTwo || $todayDate == $startDateMinusOne || $todayDate <= $startDatePlusTen))true#{else}false#end"
    },
    "internal": false
}```

Can you explain this in “business” language? this transform logic seems like an overkill to me and can be much simplified

@iamnithesh

We want to check if today’s date falls within a specific range of dates. Specifically, we want to see if today is:

  1. The same as the start date.
  2. Two days before the start date.
  3. One day before the start date.
  4. Any day up to ten days after the start date.

If any of these conditions are true, then today’s date is within the range we’re interested in. If none of these conditions are true, then today’s date is outside of that range.

1 Like

In this case you can use dateCompare transform to check

if(today is GTE startDate - 2 days AND today is LTE startDate + 10 days) then true
else false

PS: I am sure you will be able to do the dateMath and dateFormat as well as round down as required

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