From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Iain <iain(at)mst(dot)co(dot)jp> |
Cc: | Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>, Christoph Haller <ch(at)rodos(dot)fzk(dot)de>, "Alexander M(dot) Pravking" <fduch(at)antar(dot)bryansk(dot)ru>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Validity check in to_date? |
Date: | 2003-12-02 16:15:24 |
Message-ID: | 20031202081242.M87630@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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).
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Haller | 2003-12-02 16:25:51 | Re: Ooops ! :( Recovery techniques |
Previous Message | Tom Lane | 2003-12-02 14:51:00 | Re: Problem with intervals |