How do I create a check constraint that is based on age difference? - Mailing list pgsql-general

From Justin
Subject How do I create a check constraint that is based on age difference?
Date
Msg-id 01010516375400.15651@justin
Whole thread Raw
Responses Re: How do I create a check constraint that is based on age difference?
List pgsql-general
Hi all,

How do I create a 'check' constraint on a date column, so that it will only
accept dates of at least 28 years ago from the date of entry?  For example,
only allowing dates of birth of people who are older than 28.

i.e.

create table foo (name varchar(40), dob date check(date('dob') < date('now' -
28 years)));

This doesn't work.  I don't understand how to do addition, subtraction, etc
with date fields.

Regards and best wishes,

Justin Clift
Database Administrator

pgsql-general by date:

Previous
From: Lincoln Yeoh
Date:
Subject: Re: Synchronous LISTEN/NOTIFY?
Next
From: "Anthony E . Greene"
Date:
Subject: Re: Test for existence of Table