Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T3mgC-0002Gt-F8 for pgsql-sql@postgresql.org; Tue, 21 Aug 2012 11:31:28 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T3mg6-0006LZ-Rp for pgsql-sql@postgresql.org; Tue, 21 Aug 2012 11:31:27 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T3mg3-00069m-CE for pgsql-sql@postgresql.org; Tue, 21 Aug 2012 13:31:19 +0200 Received: from ip-118-90-90-161.xdsl.xnet.co.nz ([118.90.90.161]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 21 Aug 2012 13:31:19 +0200 Received: from jasen by ip-118-90-90-161.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 21 Aug 2012 13:31:19 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: generated dates from record dates - suggestions Date: 21 Aug 2012 11:14:53 GMT Organization: Dis (not Dat) Organisation Lines: 23 Message-ID: References: <201208201317.46588.gary.stainburn@ringways.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-90-161.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Pg-Spam-Score: -2.1 (--) X-Archive-Number: 201208/23 X-Sequence-Number: 36794 On 2012-08-20, Gary Stainburn wrote: > Hi folks. > > I've got a table with three dates which are populated from an external source. > I then want to have a view with two calculated dates in it, e.g. > > if date_1 is null and date_2 is null then date_a=NULL > if date_1 is not null and date 2 is null then date_a=date_1+'90 days' > if date_1 > date3 rhen date_b=date1 else date_b=date2 > etc. > > What's the best way to do this? CASE looks good. > I know it's a quite open question but I'm interested to hear different > responses "date_b" on line three, is that a typo? if not how am i to interpret it? -- ⚂⚃ 100% natural