Reputation: 8783
I'm trying to setup a mysql select query based on a given date in a datetime column. Something like:
SELECT DATE_FORMAT(colName, '%Y-%m-%d') WHERE..
But I'm unsure on how to do this correctly. I'm using php to do this.
Upvotes: 0
Views: 1058
Reputation: 1856
Following example explain the query to select date between 01-Jan-2014 and 15-Jan-2014.
SELECT
DATE_FORMAT(colName, '%Y-%m-%d') AS colName
FROM
`my_table`
WHERE
DATE_FORMAT(colName, '%Y-%m-%d') >= '2014-01-01' AND DATE_FORMAT(colName, '%Y-%m-%d') <= '2014-01-15'
Upvotes: 1