Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I would like to take the number of months between today and the Date selected into the field named 'Value Date'.
How can i do that please ?
Thank you in advance for your help,
Sébastien.
Check Rob's response here:
You can try this:
=((Year(Today(2)) * 12) + Month(Today(2))) - ((Year(Max([Value Date])) * 12) + Month(Max([Value Date])))
Thanks a lot for your response, but it doesn't return the correct answer :
Here the field and the result:
The Expression:
= ((Year(Max([AIR Import Data]) * 12) + Month([AIR Import Data])))
==> the field [AIR Import Data] is named Value Date here
So the final calculus is wrong:
The Expression:
=((Year(Today(2)) * 12) + Month(Today(2))) - ((Year(Max([AIR Import Data]) * 12) + Month([AIR Import Data])))
Do you have an idea of the problem ?
Thank you in advance for your return,
Sébastien.
Can you try this, I made a mistake earlier:
=((Year(Today(2)) * 12) + Month(Today(2))) - ((Year(Max([AIR Import Data])) * 12) + Month(Max([AIR Import Data])))
You can also have a look at
Calculating Months difference between two dates
There is a description of an approach to define this using a variable, and also to consider the days (similar to the Age() function for years), so that End of this Month to Beginning of next month could equal to zero, not 1.
SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + 1);
or
SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + If(Day($1)>Day($2),0,1));
-->
=$(MonthDiff(Max([Value Date]), Today()))