Subject Re: [ib-support] udf crashes firebird
Author Nick Upson
>From: "Ivan Prenosil" <prenosil@...>
>Reply-To: ib-support@yahoogroups.com
>To: <ib-support@yahoogroups.com>
>Subject: Re: [ib-support] udf crashes firebird
>Date: Mon, 19 May 2003 19:14:27 +0200
>
>From: "Nick Upson" <uebridger@...>
> > >2) There is EXTRACT built-in function (not in IB4, IB5 though),
> > > to return Monday = 1, .. Sun = 7, use it that way
> > > EXTRACT(WEEKDAY FROM my_date_field - 1) + 1
> >
> > using FB1.0.2 but I can't get EXTRACT(WEEKDAY FROM 'today'- 1) + 1 to
>work
>
>That's because 'today' is string - you can't subtract numbers from string.
>Either cast it to date (or timestamp, so it can work with dialect-1 too):
>
> EXTRACT(WEEKDAY FROM CAST('today' AS TIMESTAMP) - 1) + 1
>
>or better yet use CURRENT_DATE or CURRENT_TIMESTAMP instead:
>
> EXTRACT(WEEKDAY FROM CURRENT_TIMESTAMP - 1) + 1

I thought today was a reserved word for a date, learn something new

why the -1 and +1 on the end? without them I get a result of 2 for today,
which is correct.

_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection
http://www.msn.co.uk/specials/btbroadband