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?

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";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.