X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 174004799AC for ; Sun, 2 Feb 2003 03:40:11 -0500 (EST) Received: from ece.rice.edu (ece.rice.edu [128.42.4.34]) by postgresql.org (Postfix) with ESMTP id 1E5BC47A1A6 for ; Sun, 2 Feb 2003 02:16:05 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with SMTP id A24A968A6B; Sun, 2 Feb 2003 01:16:05 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with ESMTP id 51D8B68A69; Sun, 2 Feb 2003 01:16:05 -0600 (CST) Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by ece.rice.edu (Postfix) with ESMTP id 1170868A68; Sun, 2 Feb 2003 01:16:04 -0600 (CST) Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.36 #1 (Debian)) id 18fEMF-0000as-00; Sun, 02 Feb 2003 01:16:03 -0600 Date: Sun, 2 Feb 2003 01:16:03 -0600 From: "Ross J. Reedstrom" To: "joe.guyot" Cc: pgsql-sql@postgresql.org Subject: Re: how can i convert a substring to a date? Message-ID: <20030202071603.GA2224@wallace.ece.rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , "joe.guyot" , pgsql-sql@postgresql.org References: <20030131070343.62550.qmail@web20107.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030131070343.62550.qmail@web20107.mail.yahoo.com> User-Agent: Mutt/1.4i X-Virus-Scanned: by AMaViS snapshot-20020300 X-DCC--Metrics: ece.rice.edu 1066; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/27 X-Sequence-Number: 11425 On Thu, Jan 30, 2003 at 11:03:43PM -0800, joe.guyot wrote: > greetings all! > > > and continually get different errors: > "bad date external representation 'createdate'" > or > "bad timestamp external representation 'createdate'" > > i'm sure this has an obvious solution but i can't seem to find it. > any suggestions are appreciated. Hmm, the parse is telling you it doesn't know how to express the string 'createdate' as a date or timestamp. Why is that? Because you've asked it to. I presume the fragments you quote above are part of a CREATE VIEW statement. You're asking forthe boolean result of comparing the substring expression to the string 'createdate'. What you probably want is: to_date(substr(creat,1,8),'YYYYMMDD') AS 'createdate' Here's an example of use: test=# CREATE VIEW quux AS SELECT to_date(substr(creat,1,8),'YYYYMMDD') AS "createdate", substr(creat,13) AS "User" FROM baz; CREATE VIEW test=# select * from baz; creat ----------------- 200111171623XYX (1 row) test=# select * from quux ; createdate | User ------------+------ 2001-11-17 | XYX (1 row) Ross