Skip to main content

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

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-CalcExpression.html?Highlight=expression


 


Kind regards


Themba


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):


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.


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


When the user is a few days old


 


Kind Regards


Raymond


 


Reply