Extracting number of days between 2 dates - IDN Workflow

Hi Community,

I am currently in the middle of creating the workflow and it is working as expected.
However, I now have an additional requirement to include the Number of Days between two dates.

The user identities has an attribute “End Date” and 10 days before the End Date, the workflow is run based on change in lifecycle state which sends out an email to management.

As per the new requirement, I need to include the number of days, calculated as the differentce between “End Date” and today’s date. so let’s say of the End Date is 2024-02-10 and today’s date is 2024-01-31, the workflow calculates the difference as 10 days and gives me a variable with the value 10.

I tried using Define Variable with Variable A as End Date and subtracting todays date using $.now() but I think this is not correct way to do it since it is erroring out.

Does anyone have any suggestions or a way to extract the number of days between 2 dates?

Thanks

Welcome to the developer community Umair.

Is the change in lifecycle state guaranteed to happen 10 days before the end date? I ask because if you are using the identity attributes changed trigger to trigger the workflow when the identity is 10 days away from end date, then at the time of workflow execution you know that you are 10 days from the end. There should be no need to calculate the difference in days, unless there is something I am missing about your requirements.

@umairmemon I have the same requirement. I need to extract the number of days between current date and lastlogindate and populate it in the body of the email.
Could you please let me know if you managed to achieve this? If yes, may I please ask for the details?

Cheers,
Sudha