Search Postgresql Archives

Re: date ranges

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

 




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



---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly

[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