Re: date ranges

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: date ranges
Дата
Msg-id 46B47AE5.1070402@iol.ie
обсуждение исходный текст
Ответ на date ranges  (jo <jose.soares@sferacarta.com>)
Список 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 по дате отправления:

Предыдущее
От: "Gregory Williamson"
Дата:
Сообщение: List tables in reverse dependancy order
Следующее
От: brian
Дата:
Сообщение: Re: date ranges