---
description: In this PostgreSQL BETWEEN Query Tutorial, we will learn about Between Operator in PostgreSQL with Numeric, Date, and Not Operator Example.
title: PostgreSQL BETWEEN Query with Example
image: https://www.guru99.com/images/postgresql-between-query.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

PostgreSQL BETWEEN retrieves values that fall within an inclusive range inside SELECT, INSERT, UPDATE, or DELETE statements. It compares an expression against two boundary values, works with numeric and date data, and supports negation through the NOT operator.

* 📌 **Core Purpose:** The BETWEEN operator matches an expression against a range defined by two values joined with AND.
* 🔢 **Inclusive Bounds:** Both boundary values are included, so BETWEEN 200 AND 280 returns rows equal to 200 or 280.
* 📅 **Numeric and Dates:** The same syntax filters numeric columns and date columns using quoted date literals.
* 🚫 **NOT Variant:** Adding NOT before BETWEEN returns every row that falls outside the specified range.
* 🖥️ **pgAdmin Execution:** The identical queries run in the pgAdmin query editor by selecting the Demo database and clicking Execute.

[ Read More ](javascript:void%280%29;) 

[![PostgreSQL BETWEEN Query with Example](https://www.guru99.com/images/postgresql-between-query.png)](https://www.guru99.com/images/postgresql-between-query.png)

## BETWEEN Operator in PostgreSQL

The **PostgreSQL BETWEEN** Operator helps in retrieving values within a range in a SELECT, UPDATE, INSERT, or DELETE statement. With the BETWEEN operator, it is possible to match a value against a range of values. Because the range is inclusive, both boundary values are treated as part of the match.

## PostgreSQL Between Query Syntax

Here is the syntax of the BETWEEN operator in [PostgreSQL](https://www.guru99.com/postgresql-tutorial.html):

expression BETWEEN value-1 AND value-2;

The expression is simply a column or a calculation. The value-1 and value-2 will create a range for us to compare the expression to.

## PostgreSQL Between Query with Numeric

We need to create an example that shows how to apply the BETWEEN operator on numeric values. Consider the Price table given below:

**Price:**

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB1.png)

Let us see the list of all books whose price is between 200 and 280:

SELECT *
FROM Price
WHERE price BETWEEN 200 AND 280;

This will return the following:

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB2.png)

Only two items have a price ranging between 200 and 280\. Note that the two boundaries are included, that is, 200 and 280.

## PostgreSQL Between Query with Date

The BETWEEN operator can be used on date values. This means that we can specify the range of date values that we need to work with. Consider the following Employees table:

**Employees:**

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB3.png)

Suppose we want to see all the employees who were employed between 2013-01-01 and 2015-01-01, we can run the following command:

SELECT *
FROM Employees
WHERE employment_date BETWEEN '2013-01-01' AND '2015-01-01';

This returns the following:

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB4.png)

## Postgres Between Query using NOT Operator

We can combine the BETWEEN operator with the NOT operator. In such a case, the list of values that are not within the specified range will be returned.

For example, to see all the items where the price is not between 200 and 280, we can run the following query:

SELECT *
FROM Price
WHERE price NOT BETWEEN 200 AND 280;

This will return the following:

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB5.png)

Two items with a price not ranging between 200 and 280 were found. Hence, their details were returned.

### RELATED ARTICLES

* [How to Create User in PostgreSQL Using PgAdmin ](https://www.guru99.com/postgresql-create-alter-add-user.html "How to Create User in PostgreSQL Using PgAdmin")
* [How to Create & Drop Table in PostgreSQL (Examples) ](https://www.guru99.com/create-drop-table-postgresql.html "How to Create & Drop Table in PostgreSQL (Examples)")
* [PostgreSQL Create View with Example ](https://www.guru99.com/postgresql-view.html "PostgreSQL Create View with Example")
* [PostgreSQL Constraints: Types with Example ](https://www.guru99.com/postgresql-constraints.html "PostgreSQL Constraints: Types with Example")

## PostgreSQL Between Query using pgAdmin

Now let’s see how these actions can be performed using pgAdmin. The queries are identical to the ones above; only the execution environment changes.

### How To Use Between Query with Numeric in PostgreSQL using pgAdmin

Here is how to use the Between query with Numeric values in [PostgreSQL using pgAdmin](https://www.guru99.com/postgresql-create-alter-add-user.html):

**Step 1)** Login to your pgAdmin account.

Open pgAdmin and login to your account using your credentials.

**Step 2)** Create a Demo Database.

1. From the navigation bar on the left, click Databases.
2. Click Demo.

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB6.png)

**Step 3)** Type the below query in the query editor:

SELECT *
FROM Price
WHERE price BETWEEN 200 AND 280;

**Step 4)** Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB7.png)

It should return the following:

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB8.png)

### With Date

To accomplish the same through pgAdmin, do this:

**Step 1)** Login to your pgAdmin account.

**Step 2)**

1. From the navigation bar on the left, click Databases.
2. Click Demo.

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB9.png)

**Step 3)** Type the query in the query editor:

SELECT *
FROM Employees
WHERE employment_date BETWEEN '2013-01-01' AND '2015-01-01';

**Step 4)** Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB10.png)

It should return the following:

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB11.png)

### Using NOT Operator

To accomplish the same through pgAdmin, do this:

**Step 1)** Login to your pgAdmin account.

**Step 2)**

1. From the navigation bar on the left, click Databases.
2. Click Demo.

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB12.png)

**Step 3)** Type the query in the query editor:

SELECT *
FROM Price
WHERE price NOT BETWEEN 200 AND 280;

**Step 4)** Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB13.png)

It should return the following:

[](https://www.guru99.com/images/1/102319%5F0509%5FPostgreSQLB14.png)

[Download the Database used in this Tutorial](https://drive.google.com/uc?export=download&id=1BqQSvYTmNz4hvZok7iYG9ha%5Fo48%5FVF2b)

## FAQs

🤖 Can AI generate PostgreSQL BETWEEN queries from a description?

Yes. AI assistants can convert plain English, such as “orders between two dates,” into a valid BETWEEN query with the correct column, bounds, and quotes. Always test the generated SQL on your schema before running it.

🧠 Can AI explain why a BETWEEN query returns unexpected rows?

Yes. AI tools can point out that BETWEEN is inclusive of both bounds, that date literals may need timestamps, and that column data types affect comparisons. Verify each explanation against your actual data and column definitions.

❓ Is the PostgreSQL BETWEEN operator inclusive of both values?

Yes. BETWEEN is inclusive, so x BETWEEN 200 AND 280 matches rows where the value equals 200, 280, or anything in between. It is equivalent to writing x >= 200 AND x <= 280.

📅 How do you use BETWEEN with dates in PostgreSQL?

Wrap each date in single quotes, for example employment\_date BETWEEN ‘2013-01-01’ AND ‘2015-01-01’. For timestamp columns, extend the upper bound or use < the next day so late-in-day times are not excluded.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/postgresql-between-query.png","url":"https://www.guru99.com/images/postgresql-between-query.png","width":"700","height":"250","caption":"PostgreSQL BETWEEN Query","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/postgresql-between.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/postgresql","name":"PostgreSQL"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/postgresql-between.html","name":"PostgreSQL BETWEEN Query with Example"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/postgresql-between.html#webpage","url":"https://www.guru99.com/postgresql-between.html","name":"PostgreSQL BETWEEN Query with Example","dateModified":"2026-07-02T11:24:12+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/postgresql-between-query.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/postgresql-between.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/juniper","name":"Juniper Willow","description":"I am Juniper Willow, a PostgreSQL Developer, offering expert guidance to help you optimize and master PostgreSQL database development.","url":"https://www.guru99.com/author/juniper","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/juniper-willow-author.png","url":"https://www.guru99.com/images/juniper-willow-author.png","caption":"Juniper Willow","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"PostgreSQL","headline":"PostgreSQL BETWEEN Query with Example","description":"In this PostgreSQL BETWEEN Query Tutorial, we will learn about Between Operator in PostgreSQL with Numeric, Date, and Not Operator Example.","keywords":"postgresql, sql","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/juniper","name":"Juniper Willow"},"dateModified":"2026-07-02T11:24:12+05:30","image":{"@id":"https://www.guru99.com/images/postgresql-between-query.png"},"copyrightYear":"2026","name":"PostgreSQL BETWEEN Query with Example","subjectOf":[{"@type":"HowTo","name":"How To Use Between Query with Numeric in PostgreSQL using pgAdmin","description":"Here is how to use Between query with Numeric in PostgreSQL using pgAdmin:","step":[{"@type":"HowToStep","name":"Step 1) Login to your pgAdmin account","text":"Open pgAdmin and Login to your account using your credentials","url":"https://www.guru99.com/postgresql-between.html#step1"},{"@type":"HowToStep","name":"Step 2) Create a Demo Database","text":"From the navigation bar on the left- Click Databases and then Click Demo","image":"https://cdn.guru99.com/images/1/102319_0509_PostgreSQLB6.png","url":"https://www.guru99.com/postgresql-between.html#step2"},{"@type":"HowToStep","name":"Step 3) Type the Query","text":"Type the below query in the query editor:","url":"https://www.guru99.com/postgresql-between.html#step3"},{"@type":"HowToStep","name":"Step 4) Execute the Query","text":"Click the Execute button","image":"https://cdn.guru99.com/images/1/102319_0509_PostgreSQLB7.png","url":"https://www.guru99.com/postgresql-between.html#step4"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Can AI generate PostgreSQL BETWEEN queries from a description?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI assistants can convert plain English, such as \"orders between two dates,\" into a valid BETWEEN query with the correct column, bounds, and quotes. Always test the generated SQL on your schema before running it."}},{"@type":"Question","name":"Can AI explain why a BETWEEN query returns unexpected rows?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI tools can point out that BETWEEN is inclusive of both bounds, that date literals may need timestamps, and that column data types affect comparisons. Verify each explanation against your actual data and column definitions."}},{"@type":"Question","name":"Is the PostgreSQL BETWEEN operator inclusive of both values?","acceptedAnswer":{"@type":"Answer","text":"Yes. BETWEEN is inclusive, so x BETWEEN 200 AND 280 matches rows where the value equals 200, 280, or anything in between. It is equivalent to writing x &gt;= 200 AND x &lt;= 280."}},{"@type":"Question","name":"How do you use BETWEEN with dates in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"Wrap each date in single quotes, for example employment_date BETWEEN '2013-01-01' AND '2015-01-01'. For timestamp columns, extend the upper bound or use &lt; the next day so late-in-day times are not excluded."}}]}],"@id":"https://www.guru99.com/postgresql-between.html#schema-59917","isPartOf":{"@id":"https://www.guru99.com/postgresql-between.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/postgresql-between.html#webpage"}}]}
```
