How to check each year value of a variable with DateTime variable?

Hi, I have activities as seen below :

I have 2 types of insurance. Insurance A and Insurance B

There’s an insurance called “Combination (mixed of A and B)”. Example :

An insurance starting from 1/6/2020 - 1/6/2024 (1 June 2020 - 1 June 2024)

5 years of insurance
Year 1 (1/6/2020) : Ins A
Year 2 (1/6/2021) : Ins B
Year 3 (1/6/2022) : Ins B
Year 4 (1/6/2023 ): Ins A
Year 5 (1/6/2024 ): Ins B

The goal is I need to output into excel “Insurance is 2 months left” per period where insurance type is Ins A. So if it’s 1/6/2020 it will write to excel “Insurance is 2 months left”. If its 1/6/2021, it will NOT write anything to excel. Can any1 help with the if logic?

So far I manage to pass the value into dictionary but I’m stuck at the year checking of the robot.

Hi @Rhys18,

Could you please share the .xaml so that it can be fully understood. Or an example input and ouput.


first split your date by “/”

step1 for each or for each row
step2 get your date in as per variable
step3 arrayvar=var.split("/"c).toarray()
step4 year=cint(arrayvar(2).tostring)-now.year
step4 month =cint(arrayvar(1).tostring)-now.month
step5 result = year +"year and “+ month+ " months left”

1 Like


There’s too much flow already in .xaml and unfortunately, I can’t share it. Sorry

but the logic I’m struggling with right now is how to check every ins type every year

Hi, I will try this later once I go to the office.


I tried to do arithmetic operation inside for each and this is what error I got :

this is the variable I have :

The error is on variable “tahun_added”

You can do like that

First split it and try to to one by one

I just marked ur solution, it works. Thanks !!

you didnt marked as solution , please mark

Oops pardon me… Done :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.