Calculate a users age based on their DOB

Hi Irina,

You would not be able to use the TODAY() function in a generated column. The system doesn’t allow non-deterministic functions. Here’s a definition of a deterministic function:

A function is deterministic if, given the same data in tables, multiple invocations produce the same result, independently of the connected user

A workaround is to use a formula to request a dynamic property. For example, consider the following scenario - a table contains the dateOfBirth column:


I can request a “dynamic property” with the following formula:

year(now())-year(dateOfBirth)

This is the result I get:

To use in the data retrieval API for the Users table, it will look as follows in the REST request:

/data/Users?property=year(now())-year(dateOfBirth)%20as%20age

Hope this helps.

Regards,
Mark

1 Like