Subject | Re: [firebird-support] Re: udf function |
---|---|
Author | geo.mastique@laposte.net |
Post date | 2007-02-01T09:10:41Z |
thanks adam,
as you said, YEARDAY for a specific date will be different during leap
years,
so i can not use it.
i thought that sql extract ( day or month or year) were not in firebird
because i list all fonction of ... interbase6
and not of firebird !
in interbase no extract but extrac exist in firebird...
so i am just going to make a procedure for a periode because there are 3
options :
1) from 2 feb to 24 feb, so one month only :
where month= feb and days between 2 and 24
2) from 20 july to 19 august, so 2 month :
where (jmonth = july and day>=20) or (month = august and day <=19)
3) from 14 march to 2 oct, so more then 2 month.
a syntaxe for first month : where (jmonth = march and day>=14)
+ a loop procedure to get "full month" : or month in ( april, may, jun,
july, august,sept)
+ a syntaxe for last month: or (month = oct and day <= 2)
--------------------------------------
This is not really a job for a UDF. It is like using a screw driver to
hit a nail into a wall - it can probably be done but this is not what
UDF's do.
UDFs are good for conversions etc. For example, Celcius to Farenheit
or Absolute value or even metaphone. I pass in something, and it
returns something based on my input.
Depending on exactly what you want, a stored procedure could be used
or even a single query.
as you said, YEARDAY for a specific date will be different during leap
years,
so i can not use it.
i thought that sql extract ( day or month or year) were not in firebird
because i list all fonction of ... interbase6
and not of firebird !
in interbase no extract but extrac exist in firebird...
so i am just going to make a procedure for a periode because there are 3
options :
1) from 2 feb to 24 feb, so one month only :
where month= feb and days between 2 and 24
2) from 20 july to 19 august, so 2 month :
where (jmonth = july and day>=20) or (month = august and day <=19)
3) from 14 march to 2 oct, so more then 2 month.
a syntaxe for first month : where (jmonth = march and day>=14)
+ a loop procedure to get "full month" : or month in ( april, may, jun,
july, august,sept)
+ a syntaxe for last month: or (month = oct and day <= 2)
--------------------------------------
This is not really a job for a UDF. It is like using a screw driver to
hit a nail into a wall - it can probably be done but this is not what
UDF's do.
UDFs are good for conversions etc. For example, Celcius to Farenheit
or Absolute value or even metaphone. I pass in something, and it
returns something based on my input.
Depending on exactly what you want, a stored procedure could be used
or even a single query.