Skip to content
clancyjane edited this page Oct 1, 2014 · 4 revisions

Using function that computes Age in months in the where clause of a sql query can cause serious performance issues.

Here is code you can use instead of calling the function dbo.fnc_age_mos

IIF(day(removal_dt) < day(birthdate) and birthdate<=removal_dt
, datediff(mm,birthdate,removal_dt) - 1
,datediff(mm,birthdate,removal_dt))

Clone this wiki locally