mediaateam
Active Member
I am using the calc element on a form. Once they make two dropdown selections (which I'm watching in the calc element), I need it to go grab two dates off of two other tables, then do a difference calculation. I know the php calculation works. Here it is with supplied dates:
Here's how I tried to modify it:
Is there some trick to using SELECT statements in the calc element? Because if I try to just do this, I don't get anything:
Code:
$datetime1 = new DateTime('2 Jan 2008');
$datetime2 = new DateTime('5 July 2012');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%y years %m months and %d days');
Here's how I tried to modify it:
Code:
$dob = SELECT date_of_birth FROM afab_student WHERE id={afab_application___student_raw};
$yrstart = SELECT day_to_calc_age FROM afab_school_year WHERE id={afab_application___school_year_raw};
$datetime1 = $dob;
$datetime2 = $yrstart;
$interval = $datetime1->diff($datetime2);
return $interval->format('%y years %m months and %d days');
Is there some trick to using SELECT statements in the calc element? Because if I try to just do this, I don't get anything:
Code:
$dob = SELECT date_of_birth FROM afab_student WHERE id={afab_application___student_raw};
return $dob;