Calculating TimeStamp Differences


#1

Trying to figure out a way to calculate the change in time fields using the lifecycle stage "became a ____ date".

The way we use them "became a lead" is when it was entered into the system, and became an MQL is when sales determined it was a good lead and started to reach out, so "became an MQL date" is when they made the first call/email.

What I want to do is have a field set that shows me the time difference between those two dates. Is that possible? And I'd want it in minutes not days.

Thanks,
Jon-Eric


#3

Hi @Jon-Eric_Cornellier, there's no way to do this in app, but through the API you could GET all contacts using the MQL and Lead properties in the request URL like this:

https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=demo&property=hs_lifecyclestage_lead_date&property=hs_lifecyclestage_marketingqualifiedlead_date.

Response:

Then you'd be able to handle the calculation yourself, convert the timestamp to minutes, and make a call to update the contact based off of your calculations using this endpoint: https://developers.hubspot.com/docs/methods/contacts/update_contact. You'd have to make sure you create a custom property that would be the place where your calculations would live in HubSpot first.