Re: Finding bogus dates

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Finding bogus dates
Date: 2007-01-18 19:38:23
Message-ID: 20070118193823.GA16764@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Thu, dem 18.01.2007, um 11:26:03 -0700 mailte Scott Ribe folgendes:
> Suppose that I have a varchar column which contains dates, and some of them
> are bogus, such as '1968-02-31'. Is it possible to specify a query condition
> "cannot be cast to a valid date". (It's legacy data, and I'm trying to clean
> it up before importing into the final schema.) There probably aren't that
> many, and I can just keep hitting pg errors one row at a time until I work
> through this, but...

You can write a function for this, read this chapter in the docu about
trapping errors:

http://www.postgresql.org/docs/8.2/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brandon Aiken 2007-01-18 19:42:23 Re: Finding bogus dates
Previous Message Jeff Amiel 2007-01-18 19:29:40 Re: drive failre, corrupt data...