Subject | Re: [firebird-support] Extract weekday |
---|---|
Author | Helen Borrie |
Post date | 2005-04-19T15:14:13Z |
At 04:17 PM 19/04/2005 +0200, you wrote:
right result either. (Monday is already 1).
A CASE expression will do it, though:
select
case when (extract (weekday from aDate) = 0) then 7
else (extract (weekday from aDate) end;
./hb
> > >Acording to Helen's book extract weekdays returns values 0..6 (0 isErp, yes. Subtract 1.
>Sunday).
> > >Could it be somewhere configured, that we get 1..7 (1 is Monday) ?
> > >Or maybe aditional approach ?
> >
> > EXTRACT (WEEKDAY FROM myDate) +1
>
>Which means 1 = Sunday, not 1 = Monday.
>
>:-)
>Now, wouldn't Stored Functions be nice... :-/Since it only has to roll Sunday over from 0 to 7, this won't give the
>
>function ExtractWeekday(aDate: DATE): SmallInt
>as
>begin
> returns extract(weekday from aDate - 1) + 1;
>end;
>
>Pitty this isn't making it into Fb 2... :-/
right result either. (Monday is already 1).
A CASE expression will do it, though:
select
case when (extract (weekday from aDate) = 0) then 7
else (extract (weekday from aDate) end;
./hb