From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | jo <jose(dot)soares(at)sferacarta(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: date ranges |
Date: | 2007-08-04 13:11:01 |
Message-ID: | 46B47AE5.1070402@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)iol(dot)ie
---------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | brian | 2007-08-04 13:18:09 | Re: date ranges |
Previous Message | cluster | 2007-08-04 11:08:13 | Safe usage of tsearch2: to_tsquery('<user input>') |