本文介绍了从数据库中过滤时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨 i希望过滤我有记录的时间 i写了这样的查询查询将获取介于12:00 Pm和05:00之间的时间Pm 从#temp中选择cs_ClinicName,FromTime,ToTime WHERE(1 = 1)和 (CONVERT之间的FromTime(时间,'12:00')和CONVERT (时间,'17:00') 或 CONVERT(时间,'12:00')和CONVERT(时间,'17:00')之间的时间间隔) 但它仅过滤此记录< pre lang =css> Micolaj11111 09:00:00.0000000 13:00 :00.0000000 我期待的是它必须给所有工作的诊所 < pre lang =css>介于12之间:00 Pm和05:00 Pm 根据记录在该时段之间的所有临床工作(< pre lang =css> 12:00 Pm和05:00 Pm) Clinic NAME FromTime ToTime Boyka 09:00:00.0000000 18:00:00.0000000 诊所名称10:00:00.0000000 18:00:00.0000000 sleek clini 10:00:00.0000000 18:00:00.0000000 Life Clinic 10:00:00.0000000 18:00:00.0000000 SAiClini 09:00:00.0000000 18:00:00.0000000 jh 10:00:00.0000000 19:00:00.0000000 Micolaj11111 09:00:00.0000000 13:00:00.0000000 牙科诊所10:00:00.0000000 19:00:00.0000000 眼科诊所09:00:00.0000000 18:00:00.0000000 ryan 01:00:00.0000000 06:00:00.0000000 < pre> 解决方案 Hi i want to filter time i have records i wrote query like this query will fetch time between 12:00 Pm and 05:00 PmSelect cs_ClinicName , FromTime ,ToTime from #tempWHERE (1=1) and( FromTime between CONVERT(Time,'12:00') and CONVERT(Time,'17:00') orToTime between CONVERT(Time,'12:00') and CONVERT(Time,'17:00') )But it is filtering only this records <pre lang="css">Micolaj11111 09:00:00.0000000 13:00:00.0000000what i a m expecting is i t must give all clinic who work between <pre lang="css">between 12:00 Pm and 05:00 Pmaccording to the records all clinic work between that time slot(<pre lang="css">12:00 Pm and 05:00 Pm)Clinic NAME FromTime ToTimeBoyka 09:00:00.0000000 18:00:00.0000000Clinic Name 10:00:00.0000000 18:00:00.0000000sleek clini 10:00:00.0000000 18:00:00.0000000Life Clinic 10:00:00.0000000 18:00:00.0000000SAiClini 09:00:00.0000000 18:00:00.0000000jh 10:00:00.0000000 19:00:00.0000000Micolaj11111 09:00:00.0000000 13:00:00.0000000Dental Clinic 10:00:00.0000000 19:00:00.0000000Eye clinic 09:00:00.0000000 18:00:00.0000000ryan 01:00:00.0000000 06:00:00.0000000<pre> 解决方案 这篇关于从数据库中过滤时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-12 12:23