2
SELECT * FROM `travail` WHERE Convert(datetime, `dateReception`)=(datetime, '01/01/2014' ) 

The value of dateReception is 2014-01-01 but it's a varchar not date

2 Answers 2

3

You can use STR_TO_DATE() function:

SELECT * FROM travail WHERE DATE(dateReception) = STR_TO_DATE('01/01/2014', '%d/%m/%Y') 
Sign up to request clarification or add additional context in comments.

1 Comment

He said that dateReception is in YYYY-MM-DD format, not DD/MM/YYYY format
2

If your varchar is like this:

8/11/2011 20:14 PM 

Then you can do something like this:

SELECT DATE_FORMAT(STR_TO_DATE('8/11/2011 20:14 PM', '%c/%e/%Y %H:%i'), '%Y-%m-%d %H:%m:%s') 

1 Comment

he said his varchar is like 2014-01-01, why do you think it might be like that?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.