How can I get the number of months between two dates?
For example, the number of months between 20/12/2010 and 20/12/2011 is 12.
Thanks for your help.
Discussion posts and replies are publicly visible
Hi Fabian,
So AFAIK, i don't think there's a direct way to do this. But using a little logic it's pretty simple. Firstly use the fn!year() on both dates and compare the years difference, if the difference is zero you can proceed with using fn!month function on both dates and get the difference between the two months. If the year difference wasn't zero then u can add those many numbers of months to the above result. So if the year diffference was 1, you add 12 months and so on.
load( local!years: year( ri!todate ) - year( ri!fromDate ), local!months: ( local!years ) * 12 + month( ri!todate ) - month( ri!fromdate ), local!months)
This might provide what you need without having to expend a lot of effort on making your own: https://community.appian.com/b/appmarket/posts/date-and-time-utilities. It has an Elapsed Function called 'elapsedMonths'
thanks dude! this actually works. for my case I wrapped around the absolute value function to so i dont get negatives...
abs() function