Transform to get difference between two dates in numeric form

Hello Folks

I have a requirement to create a transform that calculates the difference between two dates and returns the difference in days (numeric form)

Example:
Input: Identity Attribute/Account Attribute
Date 1: 06/05/2025 (MM/DD/YYYY)
Date 2: 06/08/2025 (MM/DD/YYYY)

Output: 3
( in days)

Please help if you have suggestions.

step 1: Use DateMath to calculate the difference between the two dates.
step 2 : Use DateCompare to determine if the result is positive or negative.
step 3 : Use a static transform to return the final result.

Hi @mananbhavsar7!

Unfortunately, we don’t have the ability to do date math at the moment. I’ve asked for the dateTool Velocity functionality to be enabled for Transforms like it is for email templates and other SailPoint functionality, and DevRel is working on it, but it’s not available yet.

Your best bet would be to convert the dates to epoch time, then get the difference, and then do the math to convert that number back to days.

If you can give more detail about what Date 1 and Date 2 actually are, that may help us come up with other ideas.

-Mark

1 Like

@Chaithu9110 the DateMath Transform Primitive does not let us calculate the difference between dates. It only lets us add (or subtract) a specified increment to a date.

2 Likes

Hi

Attribute is lastLoginTimestamp from AD source to calculate with the current date. If diference is >=30 days then “>30 days” should be printed in the attribute else “<30 days”.

Okay, see this post here for my thoughts on this in general (TL;DR - you likely want to look at more than just that one attribute) - Transform - Find Users' Last Activity Date (find latest date in array).

For your use case, you’ll want to find the latest date of all the relevant attributes, then do a dateCompare with now-30d as the secondDate. If the firstDate is less than second date, then return >30 days, otherwise return <30 days.

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