表中有日期时间字段,记录该行记录写入的时间。我想查询每天22:00至23:00的记录,能用SQL语句做到吗?该怎么写?

解决方案 »

  1.   

    SELECT * FROM [表名] WHERE DATEPART(hh,[日期时间字段])=22
      

  2.   

    SELECT * FROM [表名] WHERE DATEPART(hh,[日期时间字段]) between 22 and 23
      

  3.   


    select * from tb where datepart(hh,日期时间字段) = 22select * from tb where datepart(hh,日期时间字段) between 22 and 23
      

  4.   

    SELECT * FROM [表名] WHERE DATEPART(hh,[日期时间字段])=22select * from tb where datepart(hh,日期时间字段) between 22 and 23這條語句包含23-24之間的數據
      

  5.   

    请问用postgresql 怎么实现,用上面的方法报错column "hh" does not exist