0

Hello,

I wonder why the date comparison does not work:

SELECT * FROM class_list INNER JOIN student ON class_list.student_id = student.student_id INNER JOIN teacher ON class_list.teach_id = teacher.teach_id INNER JOIN class ON class_list.class_id = class.class_id WHERE datetime > date('Y-m-d H:i:s') ORDER BY class_list_id

date('Y-m-d H:i:s') --> 2014-08-11 08:32:08

datetime --> 2014-08-01 15:00:00

I also have tried: (replacing the WHERE with) --> WHERE datetime > date('Y-m-d H:i:s')

And it also returns nothing.

This query (before the WHERE) works perfectly: SELECT * FROM class_list INNER JOIN student ON class_list.student_id = student.student_id INNER JOIN teacher ON class_list.teach_id = teacher.teach_id INNER JOIN class ON class_list.class_id = class.class_id

I would like to select the date before now only.

How?

1
Contributor
1
Reply
4
Views
3 Years
Discussion Span
Last Post by davy_yg
0

I figure it out:

$sqlstr = "SELECT * FROM class_list 
                INNER JOIN student 
                ON class_list.student_id = student.student_id
                INNER JOIN teacher
                ON class_list.teach_id = teacher.teach_id
                INNER JOIN class
                ON class_list.class_id = class.class_id WHERE datetime < '".date('Y-m-d H:i:s')."' ORDER BY class_list_id";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.