Re: date ranges

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
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:19:10
Message-ID: 6EA9628B-813F-40AD-87E5-18C5861F7FC5@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jul 31, 2007, at 11: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.

You can use a check constraint on the date column, e.g.,

CREATE TABLE dates
(
a_date date PRIMARY KEY
CHECK(a_date BETWEEN '1900-01-01'::date AND '2020-12-31')
);

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2007-08-04 15:02:50 Re: Suse RPM's
Previous Message brian 2007-08-04 13:18:09 Re: date ranges