# Add a calculated input field to a database

**URL:** <https://forum.wixstudio.com/t/add-a-calculated-input-field-to-a-database/9362>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [January 21, 2022, 12:12am UTC](https://forum.wixstudio.com/t/add-a-calculated-input-field-to-a-database/9362 "2022-01-21T00:12:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommy](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tommy/32/7745_2.png) [@tommy](https://forum.wixstudio.com/u/tommy)\
**Post date:** [January 21, 2022, 12:12am UTC](https://forum.wixstudio.com/t/add-a-calculated-input-field-to-a-database/9362/1 "2022-01-21T00:12:43Z")

</div>

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

 ![](https://us1.discourse-cdn.com/wix/original/3X/7/f/7f066e01ccec831f46e8b342ede6141b76ae49f2.png)

$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 ))}`; 

})

```

---

<div class="post-metadata">

**Author:** ![robmich](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/robmich/32/24414_2.png) [@robmich](https://forum.wixstudio.com/u/robmich)\
**Post date:** [January 22, 2022, 9:09pm UTC](https://forum.wixstudio.com/t/add-a-calculated-input-field-to-a-database/9362/2 "2022-01-22T21:09:25Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![tommy](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tommy/32/7745_2.png) [@tommy](https://forum.wixstudio.com/u/tommy)\
**Post date:** [January 24, 2022, 8:13pm UTC](https://forum.wixstudio.com/t/add-a-calculated-input-field-to-a-database/9362/3 "2022-01-24T20:13:09Z")

</div>

Thanks for your help!!!  
Solved
