Jump to content

mysql select birthday between two date


peterjc

Recommended Posts

Either use the mysql MONTH() and DAY() functions or the DATE_FORMAT() function to get just the month and day from your date of birth column and then use a BETWEEN comparison to test for the min and max values you want.

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.

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.