Subject RE: [firebird-support] UDF weekofyear
Author Thomas Steinmaurer
Hi there,

> I'm using FB 1.5 latest cr and FreeUDFLib, WIN32 platform.
>
> The function WeekOfYear returns the weeknumber according to
> International(American?) standard (Sunday first day of week), e.g.
> according to WeekOfYear last year (2003) contains 53 weeks and today
> (12 jan 2004) is week 2.
>
> According to European rules (Monday first day of week), last year
> cantains only 52 weeks and today (12 jan 2004) is week 3.
>
> The UDF-library rfunc has a function called DateToStr(d, %W) which
> calculates the week based upon Monday first day of week, but
> unfortunately return a string instead of a smallint.
>
> Is there a good UDF library which can calculate the 'correct'
> WeekOfYear?

How about casting the above result to a SMALLINT?

CAST(DateToStr(...) AS SMALLINT)



Thomas