Mautic Community Forums

Campaign rules based on date comparison

Hi guys,

I am creating a campaign in Mautic now and I was wondering if someone knows how to solve my problem.

I have a date field that represents the date of user’s last transaction. In my campaign I want to set up a rule: if the transaction happened more than 7 days ago, the user should get a tag. Once the date is less than 7 days ago, the tag should be removed.

Any idea on how to solve that?


You will have to create a segment for that and base a campaign on it. The segment filter will have to be:

[Last Transaction Date] greater than or equal "today-7"

Just don’t pick a date but input the today-7 manually into the date input field of the segment.

After that, create a campaign which assigns the contact tag. Whenever a contact reaches a transaction data which is 7 days (or more) in the past, it will go into the segment and into the campaign.

Sorry, of course it has to be [Last Transaction Date] less than or equal "today-7" (not greater)

Thanks Peter!

Do you think this will create a sliding window of dates?

What I mean: if today I setup the "greater than or equal “today-1”, (and it’s the 8th of February today), the segment will be updated with those people who’s dates are 7th and 8th, but will it be updated tomorrow with people with newer dates automatically?

Thank you once again,


Yes DL, this is exactly what will happen. The “today” is replaced with the current date when the segment is updated. So tomorrow it will have another date period than the day after tomorrow.

This works! Thanks Peter!

Great discussion as I have a related question. Is it also possible to get the current year for comparison with a custom year field (not an actual Mautic date field). So for example, I want to create a segment where [CustomYearField] is equal to the current year (without having to change the segment every year).

Thanks in advance!

Alberto, is there any way to convert your custom field to a date(time) field? It yes, two simple segment filter (greater than 1.1.2018 and less than 31.12.2018) should do it.

But: you will have to change your segment manually which should not be too much effort once a year. :wink:

Otherwise, currently there is no Mautic standard functionality to accomplish that.

Hi Peter, thank you for the quick reply. Sure, changing the segment on a yearly basis isn’t a big deal. I was just curious what is possible as I wasn’t aware you could use ‘today’ within fields. Is there documentation somewhere as to what else can be used in fields for comparison when it comes to dates?

I haven’t found any documentation on this. I think today, yesterday and tomorrow work. The rest can be accomplished with today+/-number. I think this is nothing Mautic brings with it per se but the software platform it is built with.

Got it, thanks!

> I think today, yesterday and tomorrow work

Indeed, they work.

> The rest can be accomplished with today+/-number.

That doesn’t work for me.

What actually works for me is “-X days” and “+X days” on a date field.
You can take a register date field and use “greater than or equal” “-7 days” to it, which will include all signups from 7 days ago till today.

Hi @DL, thanks for the tip. Today-X wasn’t working for me. using “-X days” worked. Thanks a lot!