sc_date_dif

I try to use sc_date_dif and sc_date_dif_2 to calculate {age}.

first, i create new text field name ‘age’ and i have {birthDate} field.
then event onload

 
$current_date=date('Y-m-d'); 
{age}=sc_date_dif($current_date, 'aaaa-mm-dd', {birthDate}, 'aaaa-mm-dd'}; 

when run the form why {age} field return days and years number like ‘#### ##’

is days

is years

then i try to use sc_date_dif_2 but it can’t use {age} as an array, return variables error in yellow box when run the form.

Re: sc_date_dif

ok, sorry, my fault.
I use sql in lookup table in age field and sc_date_dif onLoad both, that will show 2 pairs of number.

but sc_date_dif_2 still not work.

Re: sc_date_dif

Hello,

Perhaps the macro isn’t accepting php variables. Could you try to run sc_date_dif without php variables?

e.j.

{myField} = sc_date_dif_2 (“2000-05-01”, “yyyy-mm-dd”, “04/21/2004”, “mm/dd/yyyy”, 1);

regards,
Bernhard Bernsmann

[d?as]=sc_date_dif({fecha_inicio}, “d-m-Y”, {fecha_final}, “d-m-Y”);

Help :frowning:

look into the field {birthDate}. must be the same inner format and must have set local off.