Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id F07499FBA27 for ; Mon, 4 Jun 2007 09:15:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 62817-03-4 for ; Mon, 4 Jun 2007 09:15:11 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.239]) by postgresql.org (Postfix) with ESMTP id 7112A9FBC87 for ; Mon, 4 Jun 2007 09:15:10 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id m22so837791nzf for ; Mon, 04 Jun 2007 05:15:09 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=i/oYi8Xgp7mrmDcGLOfhhVXjLtR03Q99dlzZWcCdvqzG0pYF/V76fASZACDS+odpTnWSe2B2WbQR1KyOhBfjgILBNQ74h8OZcTL6MaNOwic/zbeRU+V5O8uPwaVPDghKnwmy8scLK8F0cerfGfZQqLh+MQS6WX59oqg6QfEFvC8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=DptNZayzoUneC1dzH58ALDSZRNAl1wM4jUrOcK3y2iIFHZHQmm+nzSyBk4oUgfuo1hKYYpoTjzRYHVge3pELVivZSOSz7WHqpR/LzJwWptVU0nCrIiq5ixQ3ZZBsbRYURY0kaR0D3rn7YH3nNwKK2iy3pvzB6FUFxTqPRr6hB6s= Received: by 10.142.84.3 with SMTP id h3mr210997wfb.1180959308875; Mon, 04 Jun 2007 05:15:08 -0700 (PDT) Received: by 10.142.88.4 with HTTP; Mon, 4 Jun 2007 05:15:08 -0700 (PDT) Message-ID: <162867790706040515v6fbcb622l1039a4202d70f8f9@mail.gmail.com> Date: Mon, 4 Jun 2007 14:15:08 +0200 From: "Pavel Stehule" To: "Ranieri Mazili" Subject: Re: [SQL] Jumping Weekends Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org In-Reply-To: <4663F114.4030903@terra.com.br> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4663F114.4030903@terra.com.br> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/306 X-Sequence-Number: 115129 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 : > 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 >