Forum Discussion
1 Reply
- nganapathirajuFormer Employee
Rather complex expression but its needed. There may be other solutions. you can make this a function part of javascript expression library -
$today.getFullYear() == $past.getFullYear() ? ($today.getMonth()-$past.getMonth()) : (11 - $past.getMonth()) + ($today.getMonth() + 1) + ($today.getFullYear() - $past.getFullYear() - 1) * 12
where
$today = Date.now() $past = Date.now().minusMonths(13)
You can plugin any dates and it will work.
Another expression
(($today.getFullYear() - $past.getFullYear()) * 12) - ($past.getMonth()) + $today.getMonth()
Yet Another expression
($today.getUTCMonth() - $past.getUTCMonth() ) + ( $today.getUTCFullYear() - $past.getUTCFullYear() != 0 ? ($today.getUTCFullYear() - $past.getUTCFullYear())*12 :0 )