Page header

Marketo: Math with dates? A Webhook Solution!

Challenge? Substract dates in Marketo to obtain an amount of dates or hours.

Whilst this is possible in Salesforce, it’s not possible in Marketo. At least not now, when I’m writing the blogpost.

Solution? Write your own calculation script (in PHP) and take full advantage of the Marketo Webhook functionality. But first; Make sure you know, what you need to know, about Marketo Webhooks.

Step 1. Write a simple script in PHP to substract dates. Place it on a server through FTP. Here is the script I use to get the amount of days:

<?php header(“Content-type: text/xml”);
echo ‘<?xml version=”1.0″ encoding=”UTF-8″?>’;
echo ‘<note>’;
echo’    <days>’; $start = strtotime($_GET[‘start’]); $end = strtotime($_GET[‘end’]); $seconds = $end – $start; $days = round(($seconds/60/60/24)+1); echo $days; echo ‘</days>’;
echo’    <weeks>’; $weeks = ceil($days/7); echo $weeks; echo ‘</weeks>’;
echo ‘</note>’; ?>

The script above outputs in XML, when you call the URL like this:

Step 2. Now we are ready to set up the webhook in Marketo. First start with creating your new field in Marketo that will hold date amount of days (or weeks).

You don’t have to be a coding guru to pull this off! CALCITNOW allows you to create formulas on the fly. You can acquire a CALCITNOW license at Please note that you will need to create a free SMOps account first, in order to acquire licenses.

If you have any questions, just leave them below this post.


Some extra resource suggestions for you

by our content recommendation engine

Want to know more about creating forumlas?

We can help with that!