Hi
I want to Calculate the date difference in to Months and years
form given dates
date1: 15 Jan 2022
date2: 15 Jan 2024
date2-date1
ANS= 2 years
In Appian date difference
date2-date1 is calculating only days
730
Discussion posts and replies are publicly visible
a!localVariables( local!months: elapsedMonths(ri!date2, ri!date1) - ri!gapInMonths, if( local!months > 12, a!localVariables( local!month: mod(local!months, 12), local!years: quotient(local!months, 12), local!years & " Years " & local!month & " Months" ), local!months & " Months" ) )
can we get days along with years and months ?
Yeah Use elapsed time and play with result .Here is a Sample code for you
a!localVariables( local!difference:elapsedtime(todatetime(ri!date1),todatetime(ri!date2)), concat( local!difference[1], " Years ",local!difference[2], " difference ", local!difference[3], " Days" ) )