SQL中查询一个月每天的数据,(以早八点到晚八点为一天),怎么查啊
展开全部
declare @beginDate datetime,@endDate datetime
set @beginDate='2014-01-01'
set @endDate='2014-01-31'
select * from tb
where convert(varchar(20),timestr,114) between '08:00:00' and '20:00:00'
and convert(varchar(10),timestr,120)
between convert(varchar(10),@beginDate,120) and convert(varchar(10),@endDate,120)
set @beginDate='2014-01-01'
set @endDate='2014-01-31'
select * from tb
where convert(varchar(20),timestr,114) between '08:00:00' and '20:00:00'
and convert(varchar(10),timestr,120)
between convert(varchar(10),@beginDate,120) and convert(varchar(10),@endDate,120)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询