Solved

Display age in the present

  • 22 March 2021
  • 2 replies
  • 11 views

I have a question about Extract Field date on K2..

the Field of Date, user select the date and it can show the age.

Do you have any code of it?

If ueser select 10/02/2010, so the result will display " 11 Years OLd and 03 months"

thank..

icon

Best answer by Prineel 22 March 2021, 10:18

View original

2 replies

Hi @fovimopu,

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 control
On my second data label, I create a new expression and do the same thing as the first, just change not in years, but in Months
During 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.

 

Kind Regards
Prineel

@Prineel


thank you very much 🙂




 



 


 





Reply