birthdate from mysql?

Posted on 2005-03-07
Medium Priority
Last Modified: 2012-06-22

my table has a field called birthdate, with type date. the data are stored in the form of yyyy-mm-dd

how do i select from my database, list of birthdates, sorted from the most upcoming one?

i.e. how do i select from mysql such that the "WHERE" condition is only comparing the month and date?

"SELECT * FROM user WHERE birthdate< ????????? order by ??????? " 

Question by:sutejok
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 32

Accepted Solution

ldbkutty earned 2000 total points
ID: 13483030
$month_day = date("md");  // returns "0307"

Query as :

SELECT birth_date FROM user WHERE DATE_FORMAT(birthdate, "%m%d") < '$month_day' ORDER BY DATE_FORMAT(birthdate, "%m%d") DESC

Author Comment

ID: 13483065
fab! thx!

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question