Subject RE: [firebird-support] UDF Question(s) - a couple more
Author Svein Erling Tysvær
On 16-3-2012 17:13, Kevin Stanton wrote:
> Greetings,
> I believe I'm down to just 3 UDFs and was wondering if there are any
> replacements for:
> Also, is there a place where I can get a list of all functions for FB
> 1.56 (and beyond)? I've taken a quick look but it's not jumping out at me.
>Upgrading to Firebird 2.1 or higher would give you DATEADD and DATEDIFF (see >
>For F_ADDMONTH and F_ADDYEAR you could use the Firebird provided udfs addMonth and addYear (see >

And it ought to be reasonably simple to calculate AgeInMonths on the fly:

(extract(year from current_date)-extract(year from MyBirthDate))*12+
extract(month from current_date)-extract(month from MyBirthDate)-
case when extract(day from current_date) < extract(day from MyBirthDate)
then 1 else 0 end

A couple of things to note:
- I do not have Fb 1.5 available now, and am uncertain whether current_date is supported
- I've never used F_AGEINMONTHS, but assume it truncates rather than rounds, e.g. that 29 February 2012 - 30 January 2011 should return 12 and not 13 since it hasn't reached 30 February yet (i.e. 1 March).