SQL BETWEEN Operator – Defining Range in a Condition with Examples

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
Category: SQL Operators

About Ing. Jan Zedníček - BI Developer, Finance controller

My name is Jan Zedníček and I work as a BI Developer at Kentico Software in Brno. Mostly you can see me there working in the office, but I also work partly as a freelancer. I have been working as a freelancer for many companies for more than 5 years, but Kentico is the matter of my heart. I used to work as a financial controller at companies like Aero Vodochody, banking and I also used to be a bond program manager in Unicapital Investment group. 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 (because of the rum effect, you know =) and to put them forward to anyone. Don´t worry about asking for help or writing some comments.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.