我在表里的是时间,没带日期的那种:
A班  8:00:00     16:00:00
B班  16:00:00    23:00:00
求time是属那个班的.怎么写?判断员工是上什么班的,SQl数据库,我用以下方法,老是得不出时间.比如我已经设定好了上\下班时间:
rs.open"select * from tab1 where 上班时间<='"& time &"' and 下班时间>='"& time &"'"

解决方案 »

  1.   

    先用convert函数把数据转换再做比较,其中的参数108表示将 上/下班时间转换为 hh:mm:ss 格式的字符串rs.open"select * from tab1 where convert(char,上班时间,108)<='"& time &"' and convert(char,下班时间,108)>='"& time &"'"
      

  2.   

    :应记住:ACCESS97、2000数据库 =#"& time &"#") 。SQL SerVER2000 ='"& time &"'"。目前,就这两种连接方式,动手试一下吧
      

  3.   

    如果是Access库,用Format函数来转换:rs.open"select * from tab1 where format(上班时间,'hh:mm:ss')<='"& time &"' and format(下班时间,'hh:mm:ss')>='"& time &"'"
      

  4.   

    如果是Access库,用Format函数来转换:rs.open"select * from tab1 where format(上班时间,'hh:mm:ss')<=#"& time &"# and format(下班时间,'hh:mm:ss')>=#"& time &"#"