Search Postgresql Archives

Re: date ranges

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx
---------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux