X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 17CD6D1D7E6 for ; Tue, 2 Dec 2003 10:55:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91171-08 for ; Tue, 2 Dec 2003 06:55:08 -0400 (AST) Received: from dyatel.antar.bryansk.ru (unknown [195.239.214.85]) by svr1.postgresql.org (Postfix) with ESMTP id ECFF8D1D0AE for ; Tue, 2 Dec 2003 06:55:05 -0400 (AST) Received: from fduch by dyatel.antar.bryansk.ru with local (Exim 4.24; FreeBSD) id 1AR8BO-00086p-QH; Tue, 02 Dec 2003 13:55:06 +0300 Date: Tue, 2 Dec 2003 13:55:06 +0300 From: "Alexander M. Pravking" To: Iain Cc: Karel Zak , Christoph Haller , pgsql-sql@postgresql.org Subject: Re: Validity check in to_date? Message-ID: <20031202105506.GI87728@dyatel.antar.bryansk.ru> References: <20031127141125.GC87728@dyatel.antar.bryansk.ru> <200312020927.KAA17321@rodos> <20031202095713.GB17884@zf.jcu.cz> <005201c3b8c1$52374a60$7201a8c0@mst1x5r347kymb> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <005201c3b8c1$52374a60$7201a8c0@mst1x5r347kymb> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/16 X-Sequence-Number: 16182 On Tue, Dec 02, 2003 at 07:44:54PM +0900, Iain wrote: > T've been following this thread with interest because I have a related > problem. Basically we are storing dates in CHAR fields with al the > associated problems. I'd like to do it, but changing everything to date > fields isn't practical for now, so as a stopgap solution, I want to provide > some validation at the database level. > > I tried: > > create domain ymdtest2 as char(10) constraint valid_date check > (VALUE::DATE); There's no conversion function from char(n) to date, but there's one from text to date. Try using check (VALUE::text::date). -- Fduch M. Pravking