Shubh
Novice

Calculating Age in K2 Smart Form ?

Jump to solution

I have a DateOfBirth field, on the form load I am fetching DOB of Customer and based on some check hididng and showing some fileds on the form.

My Requirenment is to calculate the age based on DOB on form initializing and show/hide some fields. Please suggest me proper a way to calulate the age from DOB ?

Thanks

Shubh

0 Kudos
Reply
2 Replies
Themba
Apprentice

Re: Calculating Age in K2 Smart Form ?

Jump to solution

Good day,


 


You can calculte age using expression that calculate difference between dates. You will subracct date of birth from system current date.


Please see below documentation for more information of time and date expression:


http://help.k2.com/onlinehelp/k2smartforms/userguide/current/default.htm#SF-ViewDesignerLayout-CalcE...


 


Kind regards


Themba

Reply
RaymondJVR
Nintex Employee
Nintex Employee

Re: Calculating Age in K2 Smart Form ?

Jump to solution

Good Day Shubh


 


You can use the day difference expression to determine the day difference between the current date and the date of birth, this will return a number value. This number value would then need to go through a conditional check to see if it is less than 365 (total amount of days in a year) in which case the result would be displayed in days OR if the number value is greater than equal to 365 then the result would be displayed in years.


 


Please see the below configuration steps in order to setup the above explained (Please see the below screenshots):


Spoiler
Step 1
On the initialize rule for the viewform the Data of Birth would need to be returned form the specified SmartObject and then needs to be diplayed in a control.
6189i65B9DA46DE6C62AA.png

The above configuration will result in the following behaviour (Please see the below screenshots):


Spoiler
When the user is a few days old
6191iED930B87ED670907.png

 


Kind Regards


Raymond


 

Reply