Subject Re: UDF weekofyear
Author arnorog
Hi Thomas,

Thank you for your reply.
According to the Embedded SQL Guide page 125 CAST() can be used
to 'convert' NUMERIC to CHARACTER only, not vice versa. Testing
confirms this, CAST(R_DATETOSTR(ordlog.MUTTIMESTAMP, '%W') AS
SMALLINT) returns nothing.

I hope someone else can help me.

Best regards,

Arno Rog


--- In firebird-support@yahoogroups.com, "Thomas Steinmaurer"
<ts@i...> wrote:
> 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