Adding x days to existing Date

Hi Team,

I am trying to add 60 days to the “inactiveStatusDate” attribute value which is in format “2023-08-13T00:00:00.000Z”.

However I am getting this below error:

Below is the transform snippet I’m using,

{
“attributes”: {
“expression”: “+60d/d”,
“roundUp”: false,
“input”: {
“attributes”: {
“input”: {
“attributes”: {
“sourceName”: “SAP HR WorkFlow Source”,
“attributeName”: “inactiveStatusDate”
},
“type”: “accountAttribute”
},
“inputFormat”: “yyyy-MM-dd’T’HH:mm”,
“outputFormat”: “ISO8601”
},
“type”: “dateFormat”
}
},
“type”: “dateMath”,
“name”: “Lapsed State Transform”
}

Can someone please help me with this issue?

Use yyyy-MM-dd'T'HH:mm:ss.SSSZ for inputFormat of dateFormat transform and try again…

It seems like the dateFormat transform is returning a null due to mismatch in inputDateFormat and the format actual date coming from inactiveStatusDate is in

yes i just added the input as “yyyy-MM-dd’T’HH:mm:ss.SSSZ” but i am getting output as “2023-08-13T00:00Z”.

I needed output in “2023-08-13T00:00:00.000Z” format

Here is the code snippet

{
“attributes”: {
“expression”: “+60d/d”,
“roundUp”: true,
“input”: {
“attributes”: {
“input”: {
“attributes”: {
“name”: “inactivestatusdate”
},
“type”: “identityAttribute”
},
“inputFormat”: “yyyy-MM-dd’T’HH:mm:ss.SSSZ”,
“outputFormat”: “ISO8601”
},
“type”: “dateFormat”
}
},
“type”: “dateMath”,
“name”: “Lapsed Lifecycle Transform”
}

So you need the transform output to be in ISO8601 format and dateMath does not return in this format, in which case you need to change your root transform to dateFormat type as below:

{
    "name": "Lapsed State Transform",
    "type": "dateFormat",
    "attributes": {
        "input": {
            "type": "dateMath",
            "attributes": {
                "expression": "+60d/d",
                "roundUp": false,
                "input": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "firstValid",
                            "attributes": {
                                "values": [
                                    {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "sourceName": "SAP HR WorkFlow Source",
                                            "attributeName": "inactiveStatusDate"
                                        }
                                    },
                                    {
                                        "type": "static",
                                        "attributes": {
                                            "value": "2199-12-31T00:00:00.000Z"
                                        }
                                    }
                                ]
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
                        "outputFormat": "ISO8601"
                    }
                }
            }
        },
        "inputFormat": "yyyy-MM-dd'T'HH:mm",
        "outputFormat": "ISO8601"
    }
}

This also includes a firstValid to take care of any null values returned for Account Attribute inactiveStatusDate

In fact, you might not need the inner dateFormat transform as the accountAttribute inactiveStatusDate is already in ISO8601 format and firstValid can directly be the input to dateMath

Thanks a ton! this worked for me :partying_face:

I have one more question.
Suppose if a user’s lifecyclestate is changed to inactive today, i need to set inactivestatus date as today’s date.
I cannot consider now as it changes everyday and after every refresh this date will change?

Is there any way i can do this via transform?Can you please help?

I suggest you post this as a new topic… that way you will have more responses

1 Like

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