• 13. 1. 2020
  • Ing. Jan Zedníček - Data & Finance
  • 0

This operator is used in SQL whenever it is needed to prove if certain value belongs to some range. This operator is used together with “AND” command which defines given range. Operator can be used in most of the clauses but is most common in WHERE for defining limiting requirement.


FROM [dbo].[Table]
WHERE [Date] BETWEEN '1900-01-01' AND '2050-12-31';

Condition can be obviously defined not only by date fields but even above any data type (where it makes sense) – numeral data types, text data types etc. Boundaries of the interval are included in the requirement with this operator.

Between can be used even in negative limitation, we would use NOT BETWEEN.

T-Sql query (as in Syntax above) is equal to query below:

FROM [dbo].[Table]
WHERE [Date] >= '1900-01-01' AND [Date] <= '2050-12-31';

BETWEEN is more elegant, shorter and makes your code clearer at a first glance. More on this operator can be accessed via this link

Rate this post

Ing. Jan Zedníček - Data & Finance

My name is Jan Zedníček and I work as a freelancer. I have been working as a freelancer for many companies for more than 10 years.
I used to work as a financial controller, analyst and manager at many different companies in field of banking and manufacturing. When I am not at work, I like playing volleyball, chess, doing a workout in the gym and I enjoy tasting of best quality rums.
I am trying to summarize all my knowledge on this website not to forget them and to put them forward to anyone.

Leave a Reply

Your email address will not be published. Required fields are marked *