Re: Validity check in to_date? - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Validity check in to_date?
Date
Msg-id 20031202081242.M87630@megazone.bigpanda.com
Whole thread Raw
In response to Re: Validity check in to_date?  ("Iain" <iain@mst.co.jp>)
List pgsql-sql
On Tue, 2 Dec 2003, 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);
>
> But it gives this error:
>
> ERROR:  cannot cast type character to date
>
> I also tried:
>
> create domain test char(10) check (CAST(VALUE AS DATE));

I'd try CAST(CAST(VALUE AS TEXT) AS DATE)

There's a text->date conversion, but not one from character(n).



pgsql-sql by date:

Previous
From: Christoph Haller
Date:
Subject: Re: Ooops ! :( Recovery techniques
Next
From: Bob Smith
Date:
Subject: Re: Problem with intervals