I have the following query:
SELECT COUNT(*) FROM leads WHERE create_date > '06:00' AND create_date < '18:00';
SELECT COUNT(*) FROM leads WHERE create_date > '06:00' AND create_date < '18:00';
However, the create_date column looks like ‘2011-08-26 10:18:01’ and i want to find everything between just those time periods, regardless of the day.
How can I just query the time from the create_date values?
How would also find all values not within those time periods?
NOT BETWEEN ….
To get the time from the date, you can use the
TIME()function.To find times outside this range, just invert everything in your where clauses.