Datapimp23
Datapimp23

Reputation: 9

MySQL Wildcard Issue

I'm trying to write a query that returns all the rows that have a specific date in the timestamp column,

The date format in the timestamp column is

2014-01-07 10:20:10

The Query I wrote does not return any results Empty set (0.00 sec)

SELECT * FROM observium.syslog WHERE 'timestamp' LIKE '2014-01-07%';

Any idea how I can do this right?

Upvotes: 0

Views: 144

Answers (1)

Aziz Shaikh
Aziz Shaikh

Reputation: 16544

Try using the DATE() function:

SELECT * FROM observium.syslog WHERE DATE(`timestamp`) = '2014-01-07'

Or try the DATE_FORMAT():

SELECT * FROM observium.syslog WHERE DATE_FORMAT(`timestamp`, '%Y %m %d') = DATE_FORMAT('2014-01-07', '%Y %m %d')

Upvotes: 3

Related Questions