Skip to content
Advertisement

SQL Date Range Specification, Explicit vs BETWEEN()

My understanding of SQL is that

is the same as

But I’m getting completely different ResultSets when the only difference in the queries is the date range specification.
The correct dates are being returned but the data is different.
This is happening in both Teradata and HANA.

Am I missing something?

EDIT:

enter image description here

enter image description here

AS POINTED OUT THIS IS THE RESULT OF A TYPO IN MY CODE
I was comparing something in production with a requested change. Thank you for the sharp eyes, my eyes obviously too tired on a Saturday to see it.

Advertisement

Answer

Your date ranges are NOT the same, regardless of query syntax used

These are syntactically equivalent:

But the safest method of describing a date range is to use a combination of >= with < as in:

This latter method works accurately regardless of how precise the time data is

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement