从Mysql日期格式获得月份和年份m / d / y并与今天的月份和年份进行比较

I have mysql date format m/d/y as varchar like 03/12/2015 for 12 March 2015. Now I want to count all the result from mysql table in which the month & year are the same as of today's date.

I am using following query, but no sucess

SELECT * FROM student where DATE_FORMAT(regd_date,'%m/%y')=DATE_FORMAT(now(),'%m/%y')"

Thanks for any help

You will first need to use STR_TO_DATE() to convert your varchar column to a date before using DATE_FORMAT().

SELECT * FROM student
WHERE DATE_FORMAT(STR_TO_DATE(regd_date, '%m/%d/%Y'),'%m/%y') = DATE_FORMAT(now(),'%m/%y')

Adjust the format for STR_TO_DATE() accordingly.

Note: I would discourage storing dates as varchars.