Re: date ranges - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: date ranges
Date
Msg-id 46B47AE5.1070402@iol.ie
Whole thread Raw
In response to date ranges  (jo <jose.soares@sferacarta.com>)
List pgsql-general
On 31/07/2007 17:26, jo wrote:

> I would like to know if there's a simple way to customize the range for
> dates,
> to avoid people insert dates before 1900 and after 2020, for example.

How about a check constraint on the date column? Something like -

create table the_table (
   the_date date,
   ....etc...
   check (the_date >= '1900-01-01' and the_date <= '2020-12-31')
);

Then you just need to handle in your application the error raised when
someone enters an incorrect date.

HTH,

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

pgsql-general by date:

Previous
From: "Gregory Williamson"
Date:
Subject: List tables in reverse dependancy order
Next
From: brian
Date:
Subject: Re: date ranges