求一个时间的筛选判断的问题,求高手帮忙看下

tommyleeyoyo 2015-12-02 04:07:34


这是我的一个查询结果 我想添加条件使
当 inteventid=9 并且 vchroccureventbegintime的时间介于 7:00:00-8:30:00时
inteventid=1 并且 vchroccureventbegintime 大于9:00:00 的结果
诶 这个判断自己不太会 所以请教了 附带我的语句


select fApplyInHospital.intsectionid,fApplyOperation.intSequence, fApplyInHospital.intpatientid,
fOccurEvent.inteventid,fOccurEvent.vchrOccurEventBeginTime
from fApplyOperation
left join fApplyInHospital on fApplyOperation.intPatientID=fApplyInHospital.intPatientID
left join fDoOperation on fApplyOperation.intapplyid=fDoOperation.intapplyid
left join fOccurEvent on fDoOperation.intDoOperationID=fOccurEvent.intDoOperationID
where fApplyOperation.intSequence=1
...全文
126 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tommyleeyoyo 2015-12-02
  • 打赏
  • 举报
回复
从 varchar 数据类型到 datetime 数据类型的转换产生一个超出范围的值
Yole 2015-12-02
  • 打赏
  • 举报
回复
datepart(hh, vchroccureventbegintime)*100+datepart(MINUTE, vchroccureventbegintime) 解释: 取小时*100,加分钟 得到的数字和 700 与830比较
Yole 2015-12-02
  • 打赏
  • 举报
回复
where 后面加上条件试一试 ((inteventid=9 and datepart(hh, vchroccureventbegintime)*100+datepart(MINUTE, vchroccureventbegintime)between 700 and 830) or (inteventid=1 and datepart(hh, vchroccureventbegintime)*100+datepart(MINUTE, vchroccureventbegintime)>=900))
tommyleeyoyo 2015-12-02
  • 打赏
  • 举报
回复
日期可以不管, 我只通过 小时分钟来判断 ~~~~

22,301

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧