Jump to content

mysql select birthday between two date


peterjc

Recommended Posts

I would like to know how to get the people birthday between two date.

 

Example: i want to select all people birthday from February 3 to March 15.  Could someone show me or give me idea how to write the SQL query to select between the day and month?

 

Thank.

Link to comment
Share on other sites

really sorry guy.  I know a bit how to use month() day() and DATE_FORMAT() actually, but i really

can not figure out how to write the sql statement for this case!  Could you please write an example?

 

Example: SELECT mem_dob FROM `membership` WHERE mem_dob BETWEEN .......

 

I really does not know how to continue at the end

 

Thank in advance.

 

Link to comment
Share on other sites

After try for several hours, if finallly come out with this:

 

SELECT *

FROM `membership`

WHERE date_format( mem_dob, '%m-%d' )

BETWEEN date_format( '2009-02-03', '%m-%d' )

AND date_format( '2009-03-15', '%m-%d' )

 

Could someone please tell me will this code work correctly? I have try it seem to be correct but may be

there are some case that i do not considered.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.