Discussions
Categories
 17.9K All Categories
 3.4K Industry Applications
 3.3K Intelligent Advisor
 63 Insurance
 536.4K OnPremises Infrastructure
 138.3K Analytics Software
 38.6K Application Development Software
 5.8K Cloud Platform
 109.5K Database Software
 17.5K Enterprise Manager
 8.8K Hardware
 71.1K Infrastructure Software
 105.3K Integration
 41.6K Security Software
How to Subtract multiple instance dates to one another, also considering Blank as an Input?
Hi OIA community,,
I have a problem Statement as, wants to subtract N number of Input dates from each other in the same instance considering blank and duplicate dates in an Input as well. Need to find out from 4 instance which instances difference is <=30 months and need to know which instance ?? In the below example it is Instance 3 , 4 and 1. All 4 below instance is 1 data set. Below is the business requirement to code.
Example 1 : Entity = Bill , Occurrence date = (User Input date) , System date = 20220623
1 20210301(15 months from system date) Difference in dates 1 and 2 = 69 Months
2 20150601(84 months from system date) Difference in dates 2 and 3 = 66 Months
3 BLANK (18 months Default) Difference in dates 3 and 4 = 3 Months (Blank)
4 20210301(15 Months from system date) Difference in dates 1 and 4 = 0 Months (Duplicate)
Difference in dates 4 and 2 = 69
Difference in dates 1 and 3= 3 months
Answer Expectation =
 Which Instance was responsible for <=30 months difference.
 Store the each date difference in number format in variable. (Need to use this in further logic)
Thanks
Shital
Answers

Hi Shital
I'm sorry but your example is not clear (to me). Could you please  for example  please detail the following
1) Each attribute that is stored in the entity
2) What you mean by the following
"Example 1 : Entity = Bill , Occurrence date = (User Input date) , System date = 20220623
1 20210301(15 months from system date) Difference in dates 1 and 2 = 69 Months"
So the entity is called "the bill". The user enters an occurrence date (per bill?) and there is the system date.
Instance one "20210301" is this the occurrence date? Let's assume it is.
So the difference between the occurrence date and the system date is 15 months.
Then you say "Difference in dates 1 and 2 = 69 months"
What is date one, date two? Are you referring to the instances?
Instance 1 : Occurrence Date 20210301 System Date 20220623 therefore 15 months from system date
Instance 2 : Occurrence Date 20150631 System Date 20220623 therefore 84 months from system date
Thus 84 minus 15 = 69?
That's going to be a challenge unless you can uniquely identify the previous instance in some sort of order  using an iterative inferred entity and relationships like the next instance and the previous instance which has been discussed here before.
Then the next two instances (instance 3 and instance 4) do not seem to follow the same pattern, especially instance 4.
3 BLANK (18 months Default) Difference in dates 3 and 4 = 3 Months (Blank)
4 20210301(15 Months from system date) Difference in dates 1 and 4 = 0 Months (Duplicate)
Why does instance three compare with instance 4, rather than instance 2 (as in the previous two instances?)
I would suggest that you need to break the logic down into much smaller components, such as :
Relating each instance to the other instances you intend to compare using a rule, creating the intermediate attributes to handle the month difference between each instance and finding the highest month difference for any instance with it's other instances.
In it's current state I would say it looks like a) there are requirements that are not clear and b) the rulebased logic is hard to discern and c) you certainly will need to approach this iteratively, and most likely create one or more inferred entities and relationships to support a structure that allows you to make the calculations.
R

Hi Richard,
Till here you understanding is correct, I have 1 entity = BILL , and it has 1 variable (Date) = Occurrence date and bill entity have 4 instance as stated above.
Instance 1 should be minus with 2, 3 and 4 , (3 pairs)
then instance 2 should be minus with only 3 and 4 (2 pairs) (why not 1??, we have already done above)
and instance 3 minus with 4 (1 pair), why not others?? (they are covered in 3 pairs)
The other combination is covered above and hence the below 6 pair of differences.
Instance 1 : Occurrence Date 20210301 System Date 20220623 therefore 15 months from system ,difference of instance 1 to instance 2 ,Thus 84 minus 15 = 69? (This is correct)
Instance 2 : Occurrence Date 20150631 System Date 20220623 therefore 84 months from system date, difference of instance 2 to instance 3 , Thus 8418 = 66 months.
Difference in dates Instance 4 and Instance 2 = 69
Furthermore,
Instance 3: Occurrence Date =BLANK (18 months Default) Difference in dates 3 and 1 = 3 Months(1815) (Blank) (This is requirement is the date is blank, directly assume as 18 months).
Difference in dates Instance 3 and Instance 2= 66 months (This is irrelevant as we have already done above)
Instance 4:Occurrence Date = 20210301(15 Months from system date) Difference in dates 1 and 4 = 0 Months (Duplicate), Thus 1515 = 0
Final combination : Difference in dates Instance 3 and Instance 4 = 0 months
Remaining combinations are .
Why does instance three compare with instance 4, rather than instance 2 (as in the previous two instances?)
Yes, you need to compare each instance with the remaining ones and hence that breakdown I gave down below. According to combination formula there will be 6 cross pairs if there are 4 instances. There are above 4 and 2 below.
Unfortunately, this is the requirement and this is exactly where I am stuck.
can you give any example for below, I think that this will help
Relating each instance to the other instances you intend to compare using a rule, creating the intermediate attributes to handle the month difference between each instance and finding the highest month difference for any instance with it's other instances.

Hi
Thanks for the explanation, that makes it a bit clearer.
So you have a bill entity with the basic attributes:
You could create relationships between different instances of the bill entity. Either manually provided or using IsMemberOf() to infer membership of a relationship to fit your scenario. So you can relate the instances with each other. You can as many reference relationships as you need in the project.
Then from that point, you can calculate the difference numbers you are looking for, using functions like For() to retrieve values from the related entity instance and get the month difference. Then you can create a Boolean to indicate which instances had a difference greater than 30.
This is just an example based on the limited data you have given. Irrespective of the actual reality, I suspect that you will need a selfreferencing relationship to connect different instances of the bill together to be able to perform your arithmetic.
For reference : compare an entity instance to a subset of entity instances https://documentation.custhelp.com/euf/assets/devdocs/cloud22b/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Work_with_rules/Write_rules_using_ent_and_rel/Example_Compare_one_inst_to_subset_inst_same_entity.htm
You could also potentially create an inferred entity that is a child of the bill in which you can infer the children you need. Then proceed in the same way to compare the parent instance to the child. https://documentation.custhelp.com/euf/assets/devdocs/cloud22b/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Work_with_rules/Write_rules_using_ent_and_rel/Example_Compare_one_inst_to_other_inst_same_entity.htm
Regards