pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedJumping Weekends
2+ messages / 2 participants
[nested] [flat]
* Jumping Weekends
@ 2007-06-04 11:01 Ranieri Mazili <ranieri.oliveira@terra.com.br>
0 siblings, 1 reply; 2+ messages in thread
From: Ranieri Mazili @ 2007-06-04 11:01 UTC (permalink / raw)
To: pgsql-general@postgresql.org; pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] Jumping Weekends
@ 2007-06-04 12:15 Pavel Stehule <pavel.stehule@gmail.com>
parent: Ranieri Mazili <ranieri.oliveira@terra.com.br>
0 siblings, 0 replies; 2+ messages in thread
From: Pavel Stehule @ 2007-06-04 12:15 UTC (permalink / raw)
To: Ranieri Mazili <ranieri.oliveira@terra.com.br>; +Cc: pgsql-general@postgresql.org; 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.oliveira@terra.com.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
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-06-04 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-06-04 11:01 Jumping Weekends Ranieri Mazili <ranieri.oliveira@terra.com.br>
2007-06-04 12:15 ` Pavel Stehule <pavel.stehule@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox