Calculate date of birth from a given age

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
muppet
Forum Newbie
Posts: 22
Joined: Sun Jan 25, 2004 2:01 pm

Calculate date of birth from a given age

Post by muppet »

Hi Peeps,

I have a db_field storing date of birth (DOB), I would like a user to be able to pull out all records where the DOB means that they are the age that the use has entered as search criteria.

Confused??? I am!!!!!!!

Any suggestions greatfully recieved. 8O
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Code: Select all

SELECT * FROM blah WHERE dob BETWEEN '1969-05-24' AND '1972-09-12'
And you work out what dates to put in the query from whatever the user has selected. If they want people older than 35, take todays date and remove 35 years from it.
Post Reply