Add a calculated input field to a database

Hello,
I would love to get a little help. I built a form that a third party is supposed to fill out. One of the fields in the form is to select a date for the year of birth. Next to it I added a calculated field which is of the input text type which is supposed to update the database the age of the respondent. I see that the field is updated but after submitting the form the field in the database remains empty
Thanks TK

$w . onReady (() => {
$w ( “#datePicker1” ). onChange (() => {

    var  todaysDate  =  **new**  Date (). getFullYear (); 

    let  inputDate  =  $w ( "#datePicker1" ). value ; 
    var  inputDateyear  =  inputDate . getFullYear (); 

    $w ( "#input21" ). show (); 
    $w ( "#input21" ). value  =  ` ${ String ( todaysDate  -  Number ( inputDateyear ))}`; 

})

Hi Tommy. Try setting the value in the dataset directly.

$w (“#CastingDatasetName”). setFieldValue (“age”, calculatedAge);

Thanks for your help!!!
Solved