View Single Post

   
  #8 (permalink)  
Old 02-26-2008, 11:04 AM
3W
 
Posts: n/a
Default Re: User defined function causes empty result set

trefork@yahoo.com (3W) wrote in message news:<498a2e3c.0307230856.660c8f2@posting.google.c om>...
> tonkuma@jp.ibm.com (Tokunaga T.) wrote in message news:<8156d9ae.0307221910.5a046fbe@posting.google. com>...
> > Another idea for isLeapYear:
> > CREATE FUNCTION isLeapYear(testYear integer)
> > returns varchar(5)
> > language sql
> > deterministic
> > no external action
> > RETURN
> > CASE
> > WHEN DAY( DATE(RTRIM(CHAR(testYear)) || '-03-01') - 1 DAY ) > 28 THEN 'TRUE'
> > ELSE 'FALSE'
> > END
> >
> > No need to know how to calculate leap year.

>
> Except that your suggestion has a big performance impact, compared to
> Knut's suggestion, which I prefer for that reason.


Plus it'll fail for years less than 1000. That may no be a problem,
but then why not just divide by 4. That'll be good between 1901-2099.
BTW, I'm not suggesting this :-)
Reply With Quote