News for hackers. Stuff that matters.
Re:SQL for Distributed Systems by LittlePeter on Wednesday October 13, 2021 @05:24AM (#28850037)
In my opinion BETWEEN should not be used because it is not clear whether the boundaries are open or closed.

See also https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use...

Re:SQL for Distributed Systems by adeelk93 on Wednesday October 13, 2021 @08:08AM (#28851123)
I thought the BETWEEN boundaries are always closed. Isn’t that pretty clear?

If you’re worried about date part precision in that comparison, you can always TRUNC before you BETWEEN.

Re:SQL for Distributed Systems by williamdclt on Wednesday October 13, 2021 @09:43AM (#28851960)
> Isn’t that pretty clear?

Nop :) That would be my guess too, but I definitely would not be certain about it, and the dozens of people that are going to read the code won't be either, some of them might make the wrong assumption, and bad things happen. I much prefer to be explicit with `>= <=` too

Re:SQL for Distributed Systems by LittlePeter on Wednesday October 13, 2021 @11:45AM (#28853666)
In the real-world world between almost always implies open boundary. Ask a hundred people to draw a point between two lines. I think none will draw a point on the line. When I enter the programming world, I carry over real-world concepts with me, and this where BETWEEN being closed gets confusing to me. Since I'm not a special snowflake, there must be other people like me who could be confused. Hence why I prefer not to use BETWEEN.
Re:SQL for Distributed Systems by adeelk93 on Wednesday October 13, 2021 @11:55AM (#28853793)
Oh I was thinking the opposite. I work between Monday and Friday, that’s a closed boundary. I have between 5 and 10 oranges, another closed boundary.
Re:SQL for Distributed Systems by simorley on Wednesday October 13, 2021 @03:00PM (#28856007)
Maybe it's a temporal vs spatial vs cardinal issue. I'm sitting "between or in between" two people ( open boundary or exclusive or non-inclusive ). Seems spatial is always open boundary. Park your car between those two trucks. I walked between two clowns.
Re:SQL for Distributed Systems by adeelk93 on Wednesday October 13, 2021 @08:26PM (#28859182)
Ah good explanation. You’re right.
Re:SQL for Distributed Systems by marcosdumay on Wednesday October 13, 2021 @10:17AM (#28852370)
On Postgres, yes.

I wouldn't count on every DBMS correctly implement the standard. Specifically, I would expect Oracle to have some crazy concept of "closed" on specific contexts that don't align with anybody's.

Anyway, in my opinion it shouldn't be used because the boundaries are both closed, and that's an incredibly bad choice. Even when it doesn't matter you have to go and confirm it doesn't matter.