There is a built in function in K2 called Date Difference that can do this:
I have created an item view with 2 date controls and 2 data labels (years and months text is just normal labels so you can ignore those). the first Date Control is emty and the second is populated with the current date.On my first data label I will display the year difference, so I created an expression using the Date/Time Difference operator under Operators in the Date & Time section. The first empty block/parameter is the interval, so i typed “Year” then you put the 2 date controls from the context browser. First the current date control, then the old date controlOn my second data label, I create a new expression and do the same thing as the first, just change not in years, but in MonthsDuring runtime, when I populate the old date control (first date control on the left), the data labels also populate with the date differences (First on in years and the second in months)
Hope this helps :) Please reach out if you have any questions/bettter explanation or even a package that you can deploy.
There is a built in function in K2 called Date Difference that can do this:
I have created an item view with 2 date controls and 2 data labels (years and months text is just normal labels so you can ignore those). the first Date Control is emty and the second is populated with the current date.On my first data label I will display the year difference, so I created an expression using the Date/Time Difference operator under Operators in the Date & Time section. The first empty block/parameter is the interval, so i typed “Year” then you put the 2 date controls from the context browser. First the current date control, then the old date controlOn my second data label, I create a new expression and do the same thing as the first, just change not in years, but in MonthsDuring runtime, when I populate the old date control (first date control on the left), the data labels also populate with the date differences (First on in years and the second in months)
Hope this helps :) Please reach out if you have any questions/bettter explanation or even a package that you can deploy.