24小时是这样写的:SELECT datediff(hh,poDate,getdate())
那么求1分钟内 怎么写?

解决方案 »

  1.   

    SELECT datediff(mi,poDate,getdate())
      

  2.   


    SELECT * from tb where datediff(mi,poDate,getdate()) <= 1SELECT * from tb where datediff(ss,poDate,getdate()) <= 60
      

  3.   


    SELECT * from tb where datediff(mi,poDate,getdate()) between 0 and 1SELECT * from tb where datediff(ss,poDate,getdate()) between 0 and 60
      

  4.   

    不行啊,我测试过了,这个是怎么计算时间差的,getdate()是当前时间吗,
      

  5.   


    getdate() --是当前时间
      

  6.   

    搞了半天终于弄明白了,是当前时间不统一。getdate()是数据库的当前时间,把时间存入数据库用的是DateTime.Now.ToString()机房的时间,因为数据库与放网页的计算机不是同一台,所以会有几分钟的偏差,所以时间比较天,小时都没问题,但是精确到分,秒,就不行了,所以不能直接在sql中进行时间比较。
      

  7.   

    SELECT * from table where datediff(mi,poDate,getdate()) between 0 and 1

    正要回,看到上条居然是楼主地帖子,呀,你的时钟不准嘛,呵呵,写程序的时候把一台服务器作为基准的时间服务器吧,比如运行程序的服务器也从数据库服务器取时间,就好像咱中国多数地区都用北京时间啦^^