1

i've issue I try this query, do not return any rows. just 0 rows. Even tho there is data matching the request..

select * from repairshop_reservations where date = DATE_FORMAT("11/06/2017 20:00:00", '%d/%m/%Y %H:%i:%s"');

Currently my content of the selected table look like this Content of table

The data value of column Date is datetime

2
  • 1
    Try: SELECT * FROM repairshop_reservations WHERE date = "11/06/2017 20:00:00"; Commented Jun 11, 2017 at 17:55
  • 1
    Default date format is as in your screenshot: where date = '2017-06-11 20:00:00' Commented Jun 11, 2017 at 17:58

2 Answers 2

1

you could use str_to_date in this way you can control the proper formatting of the date when you don't use the standard mysql format

select * from repairshop_reservations 
where date = str_to_date('11/06/2017 20:00:00', '%d/%m/%Y %H:%i:%s');
Sign up to request clarification or add additional context in comments.

4 Comments

you have an extra "
@P.Soutzikevich correct answer .. updated ..thanks
I think what the OP wants is to have the entire row returned, but it's good to have an example of the str_to_date function in the question page for others to see. You should include in your answer when it's best to use str_to_date and when not.
@P.Soutzikevich .thanks for suggestion answer updated with a brief explanation
1

You are not inserting a column in your table, so you won't have to define a data type for it. That means that, you are not making changes to the conceptual scheme of your database.

Considering that your table is implemented correctly, the SQL query you would need to give you the desirable result would be:

SELECT * FROM repairshop_reservations
WHERE date = "11/06/2017 20:00:00";

You use the WHERE clause, to filter your record and get an output with a specified condition. In plain English, what you want to do is: Select and print for me, every column from the repairshop_reservations table, that has listed date as "11/06/2017 20:00:00"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.