Re: A creepy story about dates. How to prevent it? - Mailing list pgsql-general

From Ron Johnson
Subject Re: A creepy story about dates. How to prevent it?
Date
Msg-id 1056032478.589.117.camel@haggis
Whole thread Raw
In response to Re: A creepy story about dates. How to prevent it?  (Jonathan Bartlett <johnnyb@eskimo.com>)
Responses Re: A creepy story about dates. How to prevent it?
List pgsql-general
On Thu, 2003-06-19 at 08:39, Jonathan Bartlett wrote:
> The problem is that you can't do the check on the _field_ since it has
> already been converted to a date.

You're right.  How about a "before insert" trigger?

> On 19 Jun 2003, Ron Johnson wrote:
>
> > On Thu, 2003-06-19 at 05:35, Bruno Wolff III wrote:
> > > On Thu, Jun 19, 2003 at 02:43:12 -0500,
> > >   Ron Johnson <ron.l.johnson@cox.net> wrote:
> > > >
> > > > OTOH, Andrew Snow's method (alway use ANSI standard YYYY-MM-DD)
> > > > is guaranteed to work.  Have your app convert to that format before
> > > > inserting, and then PostgreSQL is guaranteed to puke if there's
> > > > a problem.
> > >
> > > No it isn't. In 7.4:
> > > area=> select '2003-20-02'::date;
> > >     date
> > > ------------
> > >  2003-02-20
> > > (1 row)
> >
> > Whoa...
> >
> > It shouldn't be difficult, though, to create a function to validate
> > dates, and have it be an implicit CHECK on date fields.  Should it?

--
+-----------------------------------------------------------+
| Ron Johnson, Jr.     Home: ron.l.johnson@cox.net          |
| Jefferson, LA  USA   http://members.cox.net/ron.l.johnson |
|                                                           |
| "Oh, great altar of passive entertainment, bestow upon me |
|  thy discordant images at such speed as to render linear  |
|  thought impossible" (Calvin, regarding TV)               |
+-----------------------------------------------------------


pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: A creepy story about dates. How to prevent it?
Next
From: "Nigel J. Andrews"
Date:
Subject: Re: why are my SELECTs in transaction?