kryssy23
05-26-2011, 02:54 AM
hey all,
I was wondering if there is such a bit of code that can check the date of birth against the current date and if there is 18+ years stores the data but if its under 18 theres an error?
at the moment this is my code. it creates the table and inserts both entries.
create table Cust
DateOfBirth DATETIME NULL CHECK (DateOfBirth < DATEADD(yy, -18, GETDATE()));
INSERT INTO Cust (DateOfBirth) VALUES (26-04-1988);
INSERT INTO Cust (DateOfBirth) VALUES (26-04-1998);
any help would be greatly appreciated :)
I was wondering if there is such a bit of code that can check the date of birth against the current date and if there is 18+ years stores the data but if its under 18 theres an error?
at the moment this is my code. it creates the table and inserts both entries.
create table Cust
DateOfBirth DATETIME NULL CHECK (DateOfBirth < DATEADD(yy, -18, GETDATE()));
INSERT INTO Cust (DateOfBirth) VALUES (26-04-1988);
INSERT INTO Cust (DateOfBirth) VALUES (26-04-1998);
any help would be greatly appreciated :)