From: | "John D(dot) Burger" <john(at)mitre(dot)org> |
---|---|
To: | "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Finding bogus dates |
Date: | 2007-01-18 22:02:18 |
Message-ID: | 8D591D32-9DCA-426D-8203-53D10E3CC713@mitre.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Scott Ribe wrote:
> Actually, that's the core of the direct query!
>
> select * from foo where to_date(olddate,'YYYY-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 complicated by having to specify the format, but the same
> basic idea
> still would work.
But this won't work if one had a text column of dates in various
formats, right? You could use a disjunction with lots of formats in
your query - or better yet, put all the formats you can think of in a
temp table and join against it:
select * from foo
where not exists (select format from dateformats
where to_char(to_date(olddate, format), format) = olddate);
But the date casting code seems to be even more general, or at least
seems to know about many more formats than I'd be likely to dream up
on my own.
- John D. Burger
MITRE
From | Date | Subject | |
---|---|---|---|
Next Message | Jasbinder Singh Bali | 2007-01-18 22:16:27 | Re: Dynamic loading of Perl Code in Postgres functions |
Previous Message | laredotornado | 2007-01-18 22:00:23 | uninstalling postgre sql on Fedora core 5 |