Skip to content

Add fnAgeOn utility function

Hubbell, Harrison Taylor requested to merge hh_age_on into main

Defines a utility function for calculating an age based on a given birth date and "as-of" date.

The calculation is as follows:

datediff(YEAR, @birthdts, @ondts) - iif(dateadd(YEAR, datediff(YEAR, @birthdts, @ondts), @birthdts) > @ondts, 1, 0)

Using this function incurs a slight performance penalty, see documentation here. For this reason, the function is not used in any views which calculate an "Age At" value. If our database is ever updated to a version which supports UDF inlining, we will revisit.

Edited by Hubbell, Harrison Taylor

Merge request reports