Subject Re: [firebird-support] EXTRACT(WEEK FROM DATE) ??
Author Luis Madaleno
Hi,

Thanks for your help.
I thought this was an international rule. It doesn't make much sense if
if isn't.

Regards,


Luis Madaleno



Florian Hector wrote:

>>Does anyone knows if FB2 will have support for WEEK number in the
>>EXTRACT() function?
>>
>>I find many DATE related capabilities in FB and in many UDF's, but can't
>>find support for WEEK number.
>>Only to WeekDay.
>>
>>
>
>IMHO, this would not make much sense, since week number is not the same
>all over the world. For example, here in Germany you can have the case
>that the the date 02.01. in a year can be the 53rd week of the previous
>year. The rule of thumb for Germany is: The week with the first Thursday
>in a year defines the first week of the year.
>
>Use this stored procedure and adapt it to your specific needs:
>
>CREATE PROCEDURE WEEKOFYEAR (
> DATTIM TIMESTAMP)
>RETURNS (
> WEEKNR SMALLINT,
> OFYEAR SMALLINT)
>AS
>begin
> if (dattim is null) then
> begin
> weeknr = null;
> ofyear = null;
> end
> else
> begin
> /*
> week number and corresponding year relate to
> thursday of the concerning week (Mon ... Sun)
> */
> dattim = dattim - extract( weekday from (dattim - 1)) + 3
> /* orig: Sun = 0 ... Sat = 6
> to: Mon = 0 ... Sun = 6 */
> /* => Mon of week */
> /* => Thu of week */;
> weeknr = (extract( yearday from dattim) / 7) + 1;
> ofyear = extract( year from dattim);
> end
> suspend;
>end
>
>Florian
>
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Visit http://firebird.sourceforge.net and click the Resources item
>on the main (top) menu. Try Knowledgebase and FAQ links !
>
>Also search the knowledgebases at http://www.ibphoenix.com
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>