Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:17:54+00:00 2026-06-05T07:17:54+00:00

So.. to return the age based on a date type it’s really easy :

  • 0

So.. to return the age based on a date type it’s really easy :
SELECT YEAR(CURDATE()) – YEAR(DateofBirth) and we get a result set with the age of the person

But what if I need to search the people with an age range of 60-70 in the table based on their date of birthdays in this format d/m/y ( Ex: 2005-04-11). I considered it was kind of hard because it’s a different thing searching for an certain age if u have only dateofbirths instead of searching through a column where u already have their ages being counted as normal years ( 50, 60 etc )

Another problem that’s not related to the one mentioned above:

Let’s say I have a table with Medics that has their names, surnames and their speciality.
We got 17 specialities : reumatologie, o.r.l, chirurgie etc. and 108 doctors

How do I get the list of the medical specialities and the doctors that are in that range based on this format:

Ex: reumatologie – 4, o.r.l – 5, chirurgie – 10 etc

4 and 5 from the examples are the number of medics. I’ve tried concatenating and all sort of queries none of them worked properly though. Maybe will work with a case? if yes how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:17:55+00:00Added an answer on June 5, 2026 at 7:17 am

    For question 1, you can just do (not very good regarding performance though):

    SELECT YEAR(CURDATE()) - YEAR(DateofBirth) AS age
    FROM tableX
    WHERE (YEAR(CURDATE()) - YEAR(DateofBirth)) BETWEEN 60 AND 70 ;
    

    If you want performance, you can add an index on DateofBirth and use this version:

    SELECT YEAR(CURDATE()) - YEAR(DateofBirth) AS age
    FROM tableX
    WHERE DateofBirth >= MAKEDATE(YEAR(CURDATE())-70, 1) 
      AND DateofBirth < MAKEDATE(YEAR(CURDATE())-60+1, 1) ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I calculate someone's age based on a DateTime type birthday?
How do I return only the Heights which satisfy an Age criterion in R?
Return Successful Dim user = ravi Dim pass = admin objcmd.CommandText = Select *
What return type should one return from a method that is getting rows from
Why return type of a method is not considered in method overloading ? Can
i return such type IQueryable< IGrouping<int, Invoice>> List() how can i work with it?
Suppose I have a command like this: select name, age, haircolor from people where
I have this on my WHERE clause dob <= DATE_SUB(CURDATE(),INTERVAL 1 YEAR) AND dob
I want to write a method to calculate the age from the birth date,
Suppose I have this class: type Pet (name:string) as this = let mutable age

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.