Search Postgresql Archives

Re: More PostgreSQL conversion fun

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nick Wiltshire wrote:
> Hi all,
> 
> I have a varchar field in a table which contains dates in yyyy-mm-dd
> format. The problem is that some have entered invalid dates like
> 1975-01-00 and I want to convert it to a date field to avoid this
> nonsense. Is there a way to test for failure of a type conversion and
> insert a NULL on failure? 
> 

Not the question you asked, but perhaps a suitable alternative: before
attempting to convert, scan all the rows in the table looking for any
contents of that column not fitting the format yyyy-mm-dd.  Then you can
either fix them or null them out.

-- 
Guy Rouillier



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux