MySQL Forums
Forum List  »  General

Why is STR_TO_DATE failing?
Posted by: KRISTY ATKINS
Date: July 20, 2022 01:52PM

I've got a query that returns the results below.
The field is a varchar.
The query is:
"SELECT answers.AnswerText
FROM answers INNER JOIN surveys ON answers.SurveyID = surveys.RecordID
WHERE answers.AnswerText IS NOT NULL AND answers.QuestionID = 116"

If I change the query to the sql below it returns all NULL values except the one having the value 06/12/1992 10:00:00.

"SELECT STR_TO_DATE(answers.AnswerText, '%m/%d/%Y %h:%i:%s')
FROM answers INNER JOIN surveys ON answers.SurveyID = surveys.RecordID
WHERE answers.AnswerText IS NOT NULL AND answers.QuestionID = 116"

Why is mysql returrning NULL instead of the datetime?
Is there anything I can do to fix this problem?


05/07/1977 00:00:00
06/14/1989 21:00:00
12/22/1995 20:00:00
09/12/1991 00:00:00
04/01/2003 00:00:00
03/15/2014 00:00:00
03/17/2002 21:30:00
10/24/2008 00:00:00
03/12/1975 21:00:00
09/20/2016 21:30:00
04/12/1981 22:00:00
06/12/1992 10:00:00
09/04/2004 22:00:00
06/12/2005 00:00:00
12/25/2019 19:00:00
03/05/1974 13:00:00
04/16/2011 22:00:00
10/09/1998 21:00:00
04/27/1984 16:00:00

Options: ReplyQuote


Subject
Written By
Posted
Why is STR_TO_DATE failing?
July 20, 2022 01:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.