User Manual

08.14.2024

MANUAL

FAQ: I want to automatically calculate age from birthdate when registering/updating the edit screen

## Answer This can be achieved with a "[Server Script](/en/manual/table-management-server-script)". --- ## Overview Enter a birthday and calculate the current age when registering or updating data. Below is a sample in which the current age calculated based on the birthday entered in the "Date A" field is inserted into "Number A". ## How to use 1. Create a "record table". 1. Open the Editor tab from the Table Management in Management and enable "Date A" and "Number A". 1. "Create a new" "[Server Script](/en/manual/table-management-server-script)" below. For "[Server Script Condition](/en/manual/server-script-conditions)", select "After formula". ## Sample Code ##### JavaScript ``` function CalculateAge(birthdayVal) { return Math.floor((ConvertDateToNum(new Date()) - ConvertDateToNum(new Date(birthdayVal))) / 10000); } function ConvertDateToNum (date) { return date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate(); } if (utilities.InRange(model.DateA)) { model.NumA = CalculateAge(model.DateA) } else { model.NumA = 0; } ``` ## Related Information <div id="ManualList"><ul><li><a href="/en/manual/table-management-server-script">Table Management: Server Script</a><span>08.13.2024 up</span></li></ul></article> <ul><li><a href="/en/manual/server-script-conditions">Developer Function: Server Script: Condition</a><span>08.14.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.