Age checking doesn't work
Posted in 2003
Topics: Server Administration, Data Types & Schema Design
For some project we have to check ages. How do I calculate ages starting
with a birth date? I have read some posts in this group concerning ages,
and when I try for example
CREATE TABLE minors
(
name VARCHAR(50) NOT NULL,
birthdate DATE NOT NULL,
CHECK (birthdate > TODAY - 18 * 365 + 4)
);I get a syntax error. I am using dbacces to acces informix2000 (I can't find
any more relevant information about the release, very strange).
Thanks for any help!
--
Pleased to meet you
Hope you guess my name
But what's puzzling you
Is the nature of my game
"Aquila" <Braempje@Netscape.Net> wrote in message news:b9gr6u$8hr$1@reader11.wxs.nl...
> For some project we have to check ages. How do I calculate ages starting
> with a birth date? I have read some posts in this group concerning ages,
> and when I try for example
> CREATE TABLE minors
> (
> name VARCHAR(50) NOT NULL,
> birthdate DATE NOT NULL,
> CHECK (birthdate > TODAY - 18 * 365 + 4)
> );> I get a syntax error. I am using dbacces to acces informix2000 (I can't find
> any more relevant information about the release, very strange).
check must have some condition which is static and not time sensitive.
The meaning of check constraint described above changes each day. A record which
is not valid today, may become valid tomorrow. So today it will fail, and tomorrow
not.
Why don't u achieve the same result thru re-entrant triggers. In fact triggers,
in conjunction with stored procedures, is best for this. You can contact me for
this by email.
Ravi
Something along the lines of
age = extend(Current, year to day) - birthdate) units day) - 1900 units
year
will give you an interval of year to day
Then they are year(age), month(age) months and day(age) days
The big question is to do need to store this accurately and how
big is the table.
Aquila wrote:
>
> For some project we have to check ages. How do I calculate ages starting
> with a birth date? I have read some posts in this group concerning ages,
> and when I try for example
> CREATE TABLE minors
> (
> name VARCHAR(50) NOT NULL,
> birthdate DATE NOT NULL,
> CHECK (birthdate > TODAY - 18 * 365 + 4)
> );> I get a syntax error. I am using dbacces to acces informix2000 (I can't find
> any more relevant information about the release, very strange).
>
> Thanks for any help!
> --
> Pleased to meet you
> Hope you guess my name
> But what's puzzling you
> Is the nature of my game
--
Paul Watson #
Oninit Ltd # Growing old is mandatory
Tel: +44 1436 672201 # Growing up is optional
Fax: +44 1436 678693 #
Mob: +44 7818 003457 #
www.oninit.com #