Q:

Mysql Date Solar Date

The column which is for Solar date but its type is varchar I want to select all rows which is in(1395-02) interval but I only get 1 row from 2 rows 
here is what I have tried 
SELECT * FROM `products_records` 
   WHERE Date_FORMAT(`products_records`.`Inserted_Date`,'%Y-%m')='1395-02'

NOTE:Some Dates LIKE 1395-02-30 in Database were changed to 0000-00-00, Thats Why I used Varchare instead of date for this column

A:

First, note that you are using DATE_FORMAT() outside its intended purpose.  The first argument to DATE_FORMAT() is supposed to be a datetime value -- not a string -- but MySQL is very generous with its implicit casting, so it's allowing you to get away with what is technically not a valid use of the function at all.  You're actually implicitly casting your string to a date and then using a function that expects a date... but some of your dates are invalid, so that implicit cast is probably failing.  After running your query, SHOW WARNINGS; will likely reveal this.
You should actually, in theory, be using STR_TO_DATE() to convert the string to a proper datetime, then using the result of that to as the first argument of DATE_FORMAT().  
However, that's still going to be the wrong solution, because it violates a fundamental rule that you do not want to use columns as arguments to most functions in the WHERE clause... because when you do, the server has to evaluate that expression for each row in the table, and your indexes can't be used to optimize the query.  You lose what's called "sargability," and queries slow to a crawl as your table grows in size.  This is a limitation of RDBMSs in general, not just MySQL.
Far better is to use constants, WHERE inserted_date >= '1395-02-01' AND inserted_date < '1395-03-01'.  This way, if an index is available, it can dramatically improve your performance.
Almost amusingly, since your dates are in yyyy-mm-dd format, their lexical order happens to also be chronological order, so even though the query above would be evaluated using string comparisons in your current setup, the answer would still be correct, and the query plan would be optimal.  If the dates were actually stored as dates, this is still the preferred form -- not using functions in WHERE.
But also, of you want to work with invalid dates, your server needs ALLOW_INVALID_DATES included in @@SQL_MODE.  Then any month can have 31 days.  I have no idea why this is actually a feature, but here it is:

The server requires that month and day values be legal, and not merely in the range 1 to 12 and 1 to 31, respectively. With strict mode disabled, invalid dates such as '2004-04-31' are converted to '0000-00-00' and a warning is generated. With strict mode enabled, invalid dates generate an error. To permit such dates, enable ALLOW_INVALID_DATES.
http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_allow_invalid_dates

Although I've never had a reason to use invalid dates, it stands to reason that the date/time functions would choke on them also, but this setting may be what you need in order to allow those values to work as expected.

