Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Adam Rich
tgresql.org Sent: Thursday, January 18, 2007 12:26:03 PM Subject: [GENERAL] Finding bogus dates 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&qu

Re: PG not rejecting bad dates (was Re: [GENERAL] Finding bogus dates)

2007-01-18 Thread David Fetter
On Thu, Jan 18, 2007 at 06:05:37PM -0600, Ron Johnson wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 01/18/07 17:52, David Fetter wrote: > > On Thu, Jan 18, 2007 at 05:42:54PM -0600, Ron Johnson wrote: > >> > >> On 01/18/07 17:22, Scott Ribe wrote: > But this won't work if on

Re: PG not rejecting bad dates (was Re: [GENERAL] Finding bogus dates)

2007-01-18 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/18/07 17:52, David Fetter wrote: > On Thu, Jan 18, 2007 at 05:42:54PM -0600, Ron Johnson wrote: >> >> On 01/18/07 17:22, Scott Ribe wrote: But this won't work if one had a text column of dates in various formats, right? >>> Right. In my

Re: PG not rejecting bad dates (was Re: [GENERAL] Finding bogus dates)

2007-01-18 Thread Chad Wagner
On 1/18/07, Ron Johnson <[EMAIL PROTECTED]> wrote: > Right. In my case I have bad data from a source I didn't control, exported > via code that I do control which happens to output -MM-DD. Well, except > that I don't do what I need to when MM or DD are more than 2 digits, but I'm > going bac

Re: PG not rejecting bad dates (was Re: [GENERAL] Finding bogus dates)

2007-01-18 Thread David Fetter
On Thu, Jan 18, 2007 at 05:42:54PM -0600, Ron Johnson wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 01/18/07 17:22, Scott Ribe wrote: > >> But this won't work if one had a text column of dates in various > >> formats, right? > > > > Right. In my case I have bad data from a sourc

PG not rejecting bad dates (was Re: [GENERAL] Finding bogus dates)

2007-01-18 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/18/07 17:22, Scott Ribe wrote: >> But this won't work if one had a text column of dates in various >> formats, right? > > Right. In my case I have bad data from a source I didn't control, exported > via code that I do control which happens to ou

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Scott Ribe
> But this won't work if one had a text column of dates in various > formats, right? Right. In my case I have bad data from a source I didn't control, exported via code that I do control which happens to output -MM-DD. Well, except that I don't do what I need to when MM or DD are more than 2 d

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread John D. Burger
Scott Ribe wrote: Actually, that's the core of the direct query! select * from foo where to_date(olddate,'-MM-DD')::text <> olddate; The format of the exported dates matches the default date::text format because I specified the export that way. If not, the query would be a little more

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Scott Ribe
> Bad dates like 02/31/2006 will be converted to sane dates. Actually, that's the core of the direct query! select * from foo where to_date(olddate,'-MM-DD')::text <> olddate; The format of the exported dates matches the default date::text format because I specified the export that way. If n

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Brandon Aiken
l Message- From: Scott Ribe [mailto:[EMAIL PROTECTED] Sent: Thursday, January 18, 2007 3:48 PM To: Brandon Aiken; pgsql-general postgresql.org Subject: Re: [GENERAL] Finding bogus dates I didn't know to_date would do that. It's better anyway. I just continued with the "fix and t

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Scott Ribe
I didn't know to_date would do that. It's better anyway. I just continued with the "fix and try again" approach and they're only 2 bad dates out 94,000+, so I don't have a huge problem here. I can try to do some research and find the correct date, but failing that, the to_date approximation is prob

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Brandon Aiken
tt Ribe Sent: Thursday, January 18, 2007 1:26 PM To: pgsql-general postgresql.org Subject: [GENERAL] Finding bogus dates 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

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread A. Kretschmer
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

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Scott Ribe
> I suppose you could create a boolean function that does a cast, and catches > the > execption, returning NULL. Yes, I was puzzling over query syntax and didn't think about a function. That would be fine. -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice

Re: [GENERAL] Finding bogus dates

2007-01-18 Thread Tomas Vondra
> 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

[GENERAL] Finding bogus dates

2007-01-18 Thread Scott Ribe
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