在postgresql中的between and操作符作用类似于,是包含边界的

a BETWEEN x AND y 等效于 a >= x AND a <= y

 

 在postgresql中比较日期的方法有四种:

方法1:

select * from user_info where create_date >= '2015-07-01' and create_date <= '2015-08-15';

方法2:

select * from user_info where create_date between '2015-07-01' and '2015-08-15';

方法3:

select * from user_info where create_date >= '2015-07-01'::timestamp and create_date < '2015-08-15'::timestamp;

方法4:

select * from user_info where create_date between to_date('2015-07-01','YYYY-MM-DD') and to_date('2015-08-15','YYYY-MM-DD');

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
猜你喜欢
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
相关资源
相似解决方案