Date Manipulation

Hi All,

I’m attempting to perform a date difference math operation. There’s a date field I’m able to successfully pull from our PipeDrive CRM.

I am trying to determine whether (Now - [PD Date Field]) < 45 days.

The date format pulled from the API is:
2023-06-23T06:00:00.000Z

I’ve tried a few different ways to perform this using date and math functions but nothing I do appears to be correct.

Hi @Ed_Ferreira,

This will be a bit tricky to do as the direct date subtraction is not supported by Make, and instead, it will treat the date as a string when you try date subtraction. I think the way you tried is the way to go i.e using the Math function for this.

  1. You need to convert your date(both now and the date you are getting from Pipedrive) using formatDate to Unix Timestamp

{{formatDate(now; “X”)}}

  1. Now, We have two dates that resemble time in seconds, we now will subtract and then convert the resultant value to days, The X in format will represent time in seconds so, what we need to do is divide the results by second in a day i.e (60 sec * 60 minutes * 24 hrs) which will be 86400.

{{(formatDate(now; “X”) - formatDate(addDays(now; -14); “X”)) / 86400}}

This should give you a date difference in days, you can then use floor or ceil function to format the division result to get a whole number.

{{floor((formatDate(now; "X") - formatDate(addDays(now; -14); "X")) / 86400)}}

Do let me know if this works for you.

2 Likes