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). ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org