MYSQL date query syntax is not formatted properly

This is how my column looks like

  deeday
 "06/07/15"
 "02/07/15"
 "06/07/15"
 "04/07/15"
 "06/07/15"

      

The following query works well

  SELECT * FROM Bango ORDER BY STR_TO_DATE( `deday` , '%y/%m/%d' )

      

What I am missing in the following request to make it work.

 SELECT * FROM `Bango` WHERE STR_TO_DATE( `deday` , '%y/%m/%d' ) = DATE_FORMAT(NOW(),'%d/%m/%y')

      

thank

+3


source to share


2 answers


Your query might work as follows -

SELECT * FROM `Bango` WHERE STR_TO_DATE( `deday` , '%d/%m/%y' ) = curdate();

      



You can use as below, but it will kill performance, so you can remove "from your field once -

SELECT * FROM 
`Bango` 
WHERE STR_TO_DATE( replace(`deday`,'"','') , '%d/%m/%y' ) = curdate();

      

0


source


SQL LIKE Statement on DateTime Type



If the column type is date, the LIKE operator does not work without converting the value to a varchar string on the fly.

0


source







All Articles