tags:

views:

49

answers:

2

Hi all

i want to compare database field of date that has YYYY-MM-DD

format and i want to compare from MM-DD

actually i want to fetch records those have birthdays between month /selected week durations

and birthdate is stores as YYYY-MM-DD format in db table

how can i achieve this kindly help.

A: 

Within your sql you could try something like the following:

select * from people where birthdate>='10/01/2010' AND birthdate<='30/01/2010';

if you want to get more specific with months and days then you can utilise the month(birthdate) and day(birthdate) functions in mysql;

select * from people where month(birthdate)=10;

would return all your people where the month for birthdate is October.

simnom
thanx for your reply,but want to fetch specific from specific week so i want to something like thisselect * from table_name where birthdate is between week 33
Rajendra Banker
select * from table_name where birthdate>=16-08 AND birthdate<=22-08like this way
Rajendra Banker
+2  A: 

Look at this:

http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html

you can use CURDATE(), DATE_ADD() and DATE_SUB() to make date interval

Xupypr MV