Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
12 replies
Subscribers
8 subscribers
Views
5029 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi All, Currently I am working on a requirement where we need to comp
souravs
Certified Lead Developer
over 9 years ago
Hi All,
Currently I am working on a requirement where we need to compute the number of months based on start date and end date. Suppose say for example start date is 25/12/2015 and end date is 31/03/2017. The total number of months should be calculated as 15 months including the date precision. How to achieve this functionality?
OriginalPostID-183629
OriginalPostID-183629
Discussion posts and replies are publicly visible
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
I also agree with a soution using the month() function. Before some of the more recent replies I wrote the following simpler snippet (then got distracted and forgot to post).
with(
local!start: month(ri!start)+(12*year(ri!start)),
local!end: month(ri!end)+(12*year(ri!end)),
local!end - local!start
)
This example basically just calculates a sum of total months based on the month and year, disregarding the days (so 2015/12/31 to 2016/1/1 would count as 1 month since it crosses 1 month boundary) - so this would have to be tweaked if desired.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chetany
A Score Level 1
over 9 years ago
It can also be done using the fn!tointervalds() function. Here is my solution:
with(
local!interval1: fn!tointervalds(ri!startDate),
local!interval2: fn!tointervalds(ri!endDate),
local!diff: local!interval2 - local!interval1,
fn!tointeger(local!diff/30)
)
This works for the example input given by souravs. I have also tested it for other values. There still maybe a few corner cases where it does not work.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
<