Subject | RE: [firebird-support] UDF Question(s) - a couple more |
---|---|
Author | Kevin Stanton |
Post date | 2012-03-19T14:46:59Z |
Hi Set,
I think Ive removed all the dependencies. I rewrote the AgeInMonths in a
stored procedure after looking at the source code for the UDF in FreeUDFLib.
Current_Date does appear to be supported in FB 1.56. And thankfully, the
Extract method is also supported so I can get the year, month and day
parts from a date.
Now I just need to figure out an ODBC issue Im having which is really
bubbling up on the priority scale.
Cheers!
Kevin
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Svein Erling Tysvær
Sent: Monday, March 19, 2012 1:44 AM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] UDF Question(s) - a couple more
I think Ive removed all the dependencies. I rewrote the AgeInMonths in a
stored procedure after looking at the source code for the UDF in FreeUDFLib.
Current_Date does appear to be supported in FB 1.56. And thankfully, the
Extract method is also supported so I can get the year, month and day
parts from a date.
Now I just need to figure out an ODBC issue Im having which is really
bubbling up on the priority scale.
Cheers!
Kevin
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Svein Erling Tysvær
Sent: Monday, March 19, 2012 1:44 AM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] UDF Question(s) - a couple more
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:
>
> 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_m
aterial/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_m
aterial/html/langrefupd25-udf.html)
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).
HTH,
Set
[Non-text portions of this message have been removed]