在日期范围和特定时间范围之间选择 [英] Select between date range and specific time range
本文介绍了在日期范围和特定时间范围之间选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以选择日期和特定时间范围之间的记录.例如,2013年1月1日至2013年11月30日之间05:00至15:00之间的所有记录.这是我到目前为止所做的.
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?
推荐答案
您可以使用HOUR
函数在小时数上添加其他条件:
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
这篇关于在日期范围和特定时间范围之间选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文