Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
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…
Suggested Courses

580 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