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

  • SEARCH
  • Home
  • 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 8127249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:27:33+00:00 2026-06-06T07:27:33+00:00

I am looking to pull records from my MySQL database where the DAY of

  • 0

I am looking to pull records from my MySQL database where the DAY of the date-of-birth (dob) is between now and XX many days away. For example, show all birthdays that are between now and 15 days from now. I am using the formula below and it works until today’s date gets closer to the end of the month. So, if today is June 1, and I want to pull all the birthdays between now and 15 days…it works fine. But If today was June 25, it would say that no records are found as end of the 15 days is in another month.

SELECT contacts._id FROM `contacts` LEFT JOIN `groups` ON groups._id = "2"
WHERE (DAY(`dob`) BETWEEN DAY(CURDATE())
AND DAY(ADDDATE(CURDATE(), INTERVAL 15 DAY))
AND MONTH(`dob`) BETWEEN MONTH(CURDATE())
AND MONTH(ADDDATE(CURDATE(), INTERVAL15 DAY))

I have also tried using something like the code below, but it does not work with DOB data as years prior to the current year will never be found. So, the year must be ignored.

SELECT contacts._id FROM `contacts` LEFT JOIN `groups` ON groups._id = "2"
WHERE dob BETWEEN CURDATE() AND CURDATE() + 15

The dates are stored in the DB as 2012-08-27, 1982-06-18, 1963-07-26, etc. I am only interested in the MONTH-DAY information.

  • 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-06T07:27:35+00:00Added an answer on June 6, 2026 at 7:27 am

    Since your dates are already stored in date format, just add 15 days to the current date so you are finding results that fall between that range:

    SELECT * FROM table WHERE date_col BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 15 DAY)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a way to pull XML from a SQL database and
I want to pull out duplicate records in a MySQL Database. This can be
I'm using NSURLConnection to pull data from a webpage. I'm looking to find a
I'm looking to pull a specific line from a number of table that have
I'm looking to pull the latest posts from a series of specific users. In
im looking to pull 3 posts from a specific Wordpress Category. At the minute
I am looking for a way to pull the first 100 characters from a
I'm looking to use Python to pull a regular string of text from a
I'm looking to pull a table's create syntax via mysql and php. Is it
I am looking for a way to pull information from EMRs using HL7. I

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.