Jump to content

calculate age


Recommended Posts

You can insert the following in the Footer to calculated the age, and assign the value to the "Age" field after submitting:

<SCRIPT LANGUAGE="JavaScript">
function ageCalculate()
{
//get current date
var stamp = new Date(); 

//get Birthday. change "InsertRecordBirthday" if the fieldname is different
var insertDate = document.getElementById('InsertRecordBirthday').value;
var birth = new Date(insertDate);

//calculation
difference = stamp - birth;
age = Math.floor(difference / (1000 * 60 * 60 * 24 * 365.25));

//assign it to Age field 
document.getElementById('InsertRecordAge').value = age;
}

document.getElementById("caspioform").onsubmit=ageCalculate;
</SCRIPT>

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 years later...

Hi,

 

The Calculated Value form element generates dynamic calculations that automatically update as users interact with your form is now available in the current platform of Caspio. You can calculate the age of a person automatically without submitting the form and without custom programming.

You can construct the calculation using functions, logic, constants, values from other fields and SQL expressions. 

You can refer to these links: https://howto.caspio.com/datapages/datapage-components/calculated-values/

                                                                https://howto.caspio.com/function-reference/

 

Regards,

kristina

 

Link to comment
Share on other sites

  • 6 months later...
  • 3 years later...
  • 2 years later...

Hi! Caspio now offers integration with OpenAI, so you can use extensions to leverage AI to update your data based on a prompt. Here's a sample use case to get the exact age based on the provided birthday(date/time).


Request:
Calculate the age of someone born on "[@field:Birthday]" as of today.
Leave it blank if there is no value in "[@field:Birthday]"
Return only the final result as a number.


Result:

image.png

 

Change the 'Birthday' field to your right field name.

To learn more about Extensions, you can check it here: https://howto.caspio.com/integration/extensions/

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...