Select between date range and specific time range

mysql, select, sql, time

Solution

You can use the `HOUR` function to add an additional condition on the hours:

select count(*) as total from tradingaccounts accounts
inner join tradingaccounts_audit audit on audit.parent_id = accounts.id
where date(audit.date_created) between date('2013-11-01 00:00:00') AND date('2013-11-01 23:59:59') 
AND HOUR (audit.date_created) BETWEEN 5 AND 15

Problem

Is there a way to Select records between dates and specific time range. For example all the records from 2013-11-01 to 2013-11-30 between hours 05:00 to 15:00. Here what i made until now. ``` select count(*) as total from tradingaccounts accounts inner join tradingaccounts_audit audit on audit.parent_id = accounts.id where date(audit.date_created) between date('2013-11-01 00:00:00') AND date('2013-11-01 23:59:59') ``` But how am I going to set the specific time range?

Original source