Re: [SQL] Jumping Weekends

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Ranieri Mazili" <ranieri(dot)oliveira(at)terra(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Jumping Weekends
Date: 2007-06-04 12:15:08
Message-ID: 162867790706040515v6fbcb622l1039a4202d70f8f9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Hello,

you forgot on sunday. Your solution can work, but isn't too efective

you can do:

production_date := production_date +
CASE extract(dow from production_date)
WHEN 0 THEN 1 -- sunday
WHEN 6 THEN 2 -- saturday
ELSE 0 END;

there isn't slower string comparation and it's one sql statement without two.

Regards
Pavel Stehule

2007/6/4, Ranieri Mazili <ranieri(dot)oliveira(at)terra(dot)com(dot)br>:
> Hello,
> (sorry for my poor english)
>
> It's my first post here, and my doubt is very simple (I guess). I have a
> function to populate a table, into "WHILE" I have the follow piece of code:
>
> --Jump Weekend
> IF (SELECT TO_CHAR(CAST(PRODUCTION_DATE as date),'Day')) = 'Saturday' THEN
> PRODUCTION_DATE := PRODUCTION_DATE + 2;
> END IF;
>
> It's to jump weekend adding 2 days on the variable "PRODUCTION_DATE",
> the type of the variable is "DATE". But, I don't know why, it's doesn't
> work properly, it's doesn't jump weekends, it's continues normally,
> someone knows what's happen or what am I doing wrong?
>
> I appreciate any help.
> Thanks
>
> Ranieri Mazili
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Staubo 2007-06-04 12:18:47 Re: multimaster
Previous Message Vincenzo Romano 2007-06-04 12:13:21 Re: Numeric performances

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2007-06-04 13:12:30 Re: Versionning (was: Whole-row comparison)
Previous Message Ranieri Mazili 2007-06-04 11:01:40 Jumping Weekends