Re: A creepy story about dates. How to prevent it?

From: Jonathan Bartlett <johnnyb(at)eskimo(dot)com>
To: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
Cc: Bruno Wolff III <bruno(at)wolff(dot)to>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: A creepy story about dates. How to prevent it?
Date: 2003-06-19 13:39:35
Message-ID: Pine.GSU.4.44.0306190639160.16766-100000@eskimo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The problem is that you can't do the check on the _field_ since it has
already been converted to a date.

Jon

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(dot)l(dot)johnson(at)cox(dot)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(dot)l(dot)johnson(at)cox(dot)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) |
> +-----------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Haworth 2003-06-19 13:46:31 Re: A creepy story about dates. How to prevent it?
Previous Message Carlos Oliva 2003-06-19 13:04:19 FW: Allowing user to connect to a database?