floor function in a form field

Hi,

I am trying to get rid of decimals on a form field that is the result of the following on validate success event in scriptcase 6;

$current_date = date(‘Y-m-d’);
{age}= sc_date_dif($current_date, ‘aaaa-mm-dd’, {DateNaissance}, ‘aaaa-mm-dd’)/365.2425;

This returns the age of the person based on the date of birth (DateNaissance). But since there is decimals on this calculation, I need to retain only the valid age (rounding to the lowest number) using the only function I am aware off: floor ().

Anybody know’s where to put the floor code and how to use it?

Re: floor function in a form field

Just use php’s floor function.
Add this line to the end of your code.

{age} = floor({age});

Re: floor function in a form field

It works well! Thank you!

Re: floor function in a form field

Hi,
just my 2cents. If you are using MySQL let the database do the work and put the following command in your query.

SELECT …,TIMESTAMPDIFF(YEAR, dob, now()) AS age FROM …

“dob” is the date-of-birth field in your table.

jsb