Subject Re: udf function
Author Adam
--- In firebird-support@yahoogroups.com, geo.mastique@... wrote:
>
> do you now a udf function i can declare in firebird 1.5 ?
>
> i would like to find some data by searching on a date field format.
>
> i would like to extract all data for a periode,
> for example a periode from 12 july to 24 september.
> of course i want the query to return data for all years.
>
> i can do it by shaking month + day function,
> but it would be more difficult to do.
>

Hello Julien,

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.

To collect data from all years, it is going to have to look at every
record in your table, which is unecessarily expensive.

I suppose you could create a UDF to convert a timestamp to a code
representing the month and day

For example, let Jan be 10, Feb be 11, ... Dec be 22. You could then
use an integer to represent the time, eg 1712 would represent July 12.

You would then just query

select *
from mytable
where TimestampToMonthDay(SomeTimestampField) between 1712 and 1924

Adam