开发者

Date Comparision in PHP and my sql

开发者 https://www.devze.com 2023-01-11 05:10 出处:网络
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 wee

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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号