DATEDIFF Bug?

shared boundary indicates a start on either side and a connection between (no-mans land being the line) no? and if so then before you cross you should be exiting the starting boundary. Now this logic works no matter if you want to say the line is connected to Utah or Colorado.... if they share a boundary or line, there is part of the line that Colorado doesn't touch and so too Utah and that is the other side, or the start of the other boundary.....and of course the end of the exiting.

even a line has two sides no? a | b

I have been watching this - and your own diagram shows how it is working - your interpretation of your diagram is incorrect.

In your diagram - how many green lines do you have? Those green lines are the boundaries...which is 4 not 5.
In your diagram - how many red lines do you have above each circle? There are 4 red lines - 4 boundaries crossed...

You ask whether or not April's boundary was crossed - the fact is, the boundary at the beginning of April was not crossed. You should also consider the fact that the boundary at the end of August was not crossed...

April->May = 1 boundary
May->June = 1 boundary
June->July = 1 boundary
July->August = 1 boundary

No other boundaries have been crossed - so this is not a bug - it is working as designed.

1 Like

Very well stated Jeff.

http://www.sqlteam.com/article/datediff-function-demystified

1 Like

Lambda, if you go from Colorado to Utah, you cross one state line: The Colorado/Utah State Line. The line is one and the same. The distance between the end of Colorado and the start of Utah is zero because the boundary of each state is exactly the same at that point of crossing.

If you wanted to know how many states you visited, you would count the number of boundaries crossed and add one, just like how DATEDIFF works.

As for the month circle diagram, this shows a misconception about boundaries. The boundary between April and May is one and the same, not two separate circles: April | May | June | July | August. There is only one line crossed when moving between months, not two. :smile:

1 Like

This discussion is still going on???

Correct me if I'm wrong, but can't you just say "+ 1" to get that first month counted, if you want it counted? LOL