Subject | RE: [firebird-support] UDF Question(s) - a couple more |
---|---|
Author | Svein Erling Tysvær |
Post date | 2012-03-19T08:44:21Z |
On 16-3-2012 17:13, Kevin Stanton wrote:
(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).
HTH,
Set
> Greetings,And it ought to be reasonably simple to calculate AgeInMonths on the fly:
>
> I believe I'm down to just 3 UDFs and was wondering if there are any
> replacements for:
>
> F_ADDMONTH
> F_ADDYEAR
> F_AGEINMONTHS
>
>
> 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 >http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25-intfunc.html
>)
>
>For F_ADDMONTH and F_ADDYEAR you could use the Firebird provided udfs addMonth and addYear (see >http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25-udf.html)
(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).
HTH,
Set