Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f77FcD682645 for ; Tue, 7 Aug 2001 11:38:13 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 97981 for ; Tue, 07 Aug 2001 08:38:08 -0700 From: "Josh Berkus" Subject: Re: Re: Adding an INTERVAL to a variable To: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Tue, 07 Aug 2001 08:38:08 -0700 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="_===97981====davinci.ethosmedia.com===_" X-Archive-Number: 200108/101 X-Sequence-Number: 4322 This is a multi-part MIME message --_===97981====davinci.ethosmedia.com===_ Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Graham, > GC> SELECT Invoices.InvoiceDate + INTERVAL Acct.AverageDaysToPay > 'Days' Actually, all you're missing is some punctuation. Don't skimp on the :: and () ! Plus, you should use explicit CASTs wherever you remember them: SELECT Invoices.InvoiceDate + INTERVAL(CAST(Acct.AverageDaysToPay AS VARCHAR) || ' days'); Will work fine. Here I've explicitly cast the Average Days integer (if it's NUMERIC or FLOAT, you will have to use TO_CHAR()) to varchar, then concatinated it with the word "days". *Then* I convert it to INTERVAL, which will recognize '# days' as a valid expression. IMHO, you've been lucky being able to skip the parens and CASTs so far; get used to using them. -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco --_===97981====davinci.ethosmedia.com===_ Content-Type: text/plain Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 DQo= --_===97981====davinci.ethosmedia.com===_ Content-Type: text/plain Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 DQo= --_===97981====davinci.ethosmedia.com===_ Content-Type: text/plain Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 DQo= --_===97981====davinci.ethosmedia.com===_--