How to combine condition, formula and date for DocMerge ?

Hello,

I am trying to set a basic information in my DocMerge template but I am strugling and would be very happy if someone of you can help me.

Here is the basic need : I have a field that contains a DATE. If this date is in the past, I want to display it ortherwise I want to display the current date. Furthermore, I need to format the date to got it in DD.MM.YYYY format.

I tried something like that but does not work

{!formula value='ifElse('greaterThan(daysUntil($my_date_field),0), my_date_field,now())' format='DD.MM.YYYY'}

I try step by step and I got a first issue ; dayUntil works and return a positive or negative number ; but when I combine it with greaterThan, I always got 0.

I was thinkinh that there is probably a way to store the formula value as a variable and use it with basic {if} DocMerge tag but I can figure it out.

Any help / trick is welcome.

Fred