Orlando
Orlando

Reputation: 975

sql datetime comparing to date value

I know you can convert a datetime to date onmly but what if you want to compare a datetime field to a date value...? For eg.

$query = "SELECT * FROM Table WHERE date_time = '" . $date . "'"

How would I go about doing this since I have the date but not the time to compare with the datetime field in the database...?

Thanks in advance!

Upvotes: 0

Views: 850

Answers (1)

Marc B
Marc B

Reputation: 360572

SELECT *
FROM Table
WHERE DATE(date_time) = '$date'

Upvotes: 4

Related Questions