Customize

Calculate Age

Summary

Calculate the age based on the Date field and set it to another field.

How to use

To set the calculated age value, prepare the appropriate field in the Kintone app and select it in the “Age Field” parameter.

To modify the formatting of the calculated age so that it displays as “X years old” rather than just a number, follow these steps:

  1. Leave the “Age Field” parameter empty.
  2. Add a new action that runs the “Set Field Value” command. In the “Value” parameter, input the following expression:
= $1 & "years old"
  • Enter the action number which runs “Calculate Age” to the “$1” string. For example, if the action number is “3”, change the string to “$3”.

Parameters

Set Birthday, Reference Date, and Age Field.

Birthday

Select a “Date” field or “Date and time” field containing the birthday to be used in the calculation.

If you select a “Date and time” field, the time will not be considered in the calculation.

If you select a field that is inside a table, the Do will process all rows of that table. See *1 for exceptions to this behavior.

*: If you set a Condition that only applies to some table rows (such as the Condition “When Fields Value Changed”), the Do will only process the rows affected by that Condition.

Reference Date

Specify at what point in time to calculate the age.

This field is optional. If you choose not to provide it, the age will be calculated based on the date when the action is performed. The date when the action is performed is based on the “Time Zone” in the user’s Kintone profile settings. When the timezone is set to “(UTC+09:00) Osaka, Sapporo, Tokyo,” it is referred to as Japan Standard Time (JST).

To take the reference date from the field value, use an expression. In the following example, the value of the field code “date_2” is used as the reference date.

= Date_2

You can also specify the results of actions that calculate dates. For example, if you want to use the result of “Get Specific Date” as the reference date, and that action is number one, you can specify it as follows.

= $1

Age Field

Use this parameter to select the field that should receive the calculated value. This parameter is optional.

This parameter accepts the following field types:

  • Text
  • Number
  • Text area
  • Rich text

If this parameter is left empty, the calculated age will not be assigned to any field. However, other Actions will still be able to access the calculated age value.

When selecting a field in the table for “Birthday”, it is also necessary to select a field for “Age Field” from the same table.

Compatibility with krewSheet

This action is designed to work seamlessly with krewSheet.

However, the following restrictions apply to the parameter “Age Field”:

  • The results cannot be assigned to a field that was retrieved through a Lookup.
  • The following field types can be set only at the timing of record saving (e.g. “Before Record Saved Excluding Deleted"): If you want to gain more technical knowledge, refer to the krewSheet documentation .
    • Fields not included in the krewSheet view’s columns
    • Fields set to read-only in krewSheet
    • Rich text field