3 ms·
You gotta be careful when using BETWEEN. BETWEEN does a >= x AND a <= y Usually, you want a >= x AND a < y http://www.postgresql.org/docs/9.3/sta
by joevandyk 11y ago
You gotta be careful when using BETWEEN.
BETWEEN does
a >= x AND a <= y
Usually, you want
a >= x AND a < y
http://www.postgresql.org/docs/9.3/static/functions-comparison.html http://www.postgresql.org/docs/9.3/static/functions-comparis...
- brobinson 11y agoGood point! Edit: my parent post is wrong, the guide is using <, not <=, but I can't edit it now.
- vincentdm 11y agoI recently replaced all my a >= x AND a < y with BETWEEN, and then I realised I got burned by what you describe :-) It's been on the Trello to-do to fix it for weeks...
- pilif 11y agoThis is why I love the Postgres range types so much (http://www.postgresql.org/docs/9.4/static/rangetypes.html http://www.postgresql.org/docs/9.4/static/rangetypes.html). With those, you get to chose based on the value whether your ranges include the boundaries or not. Even better: you get to chose for both start and end.