I'm trying to create a table writing in SQL and I need to validate the 'Date of Birth' field
Players must be over 16 years of age
You can try this:
ALTER TABLE Players SET CHECK DOB >= DATE + (16 * 365.25);
Not tested.
LastMitch
Industrious Poster
4,177 posts since Mar 2012
Reputation Points: 132
Solved Threads: 335
Skill Endorsements: 45
Why would a person's date of birth be greater than or equal to a number?
either try
DOB >= dateadd(y,-16,getdate())
or
datediff(y,DOB,getdate()) >=16
adam_k
Veteran Poster
1,057 posts since Jun 2011
Reputation Points: 274
Solved Threads: 205
Skill Endorsements: 11