How to use CURRENT_DATE in PostgreSQL

Galaxy Glossary

How do I get today’s date in PostgreSQL using CURRENT_DATE?

CURRENT_DATE returns the server’s current date (YYYY-MM-DD) without any time-zone adjustment.

Sign up for the latest in SQL knowledge from the Galaxy Team!

Description

What does CURRENT_DATE do in PostgreSQL?

CURRENT_DATE instantly returns today’s date based on the database server’s clock. It omits the time component and ignores the client’s time zone, making it ideal for date-only comparisons and reports.

How do I call CURRENT_DATE?

Use CURRENT_DATE anywhere an expression is allowed—SELECT lists, WHERE clauses, check constraints, or default column values. No parentheses are needed because it is a special SQL keyword, not a function.

How is CURRENT_DATE typically used?

Teams compare order dates to today, stamp new records, or calculate customer tenure. Because it is evaluated once per statement, it stays consistent within the query, even if the statement spans milliseconds across midnight.

What is the exact syntax?

The keyword has no parameters; you simply write CURRENT_DATE. To store it as a default, use DEFAULT CURRENT_DATE in a column definition.

Practical examples for ecommerce data

Filter today’s orders
SELECT id, total_amount FROM Orders WHERE order_date = CURRENT_DATE;

Set default created_at
ALTER TABLE Customers ALTER COLUMN created_at SET DEFAULT CURRENT_DATE;

Find low-stock products added today
SELECT name FROM Products WHERE stock < 10 AND created_at = CURRENT_DATE;

Best practices for accuracy

Compare date columns to CURRENT_DATE only when those columns are also stored as DATE. Cast TIMESTAMP columns (order_date::date) to avoid implicit conversions that can block indexes.

Can I use CURRENT_DATE in prepared statements?

Yes. PostgreSQL resolves CURRENT_DATE when the statement executes, so the same prepared statement can run today, tomorrow, or next week and always return the correct date.

How is CURRENT_DATE different from NOW()?

NOW() returns a full timestamp with time zone and can be cast to DATE, whereas CURRENT_DATE is already a DATE. Use CURRENT_DATE for pure date logic to skip extra casting.

Key takeaway

Use CURRENT_DATE when you need an unambiguous, timezone-free snapshot of today’s date inside any SQL statement.

Why How to use CURRENT_DATE in PostgreSQL is important

How to use CURRENT_DATE in PostgreSQL Example Usage


/* Find customers who placed their first order today */
SELECT c.id, c.name, o.id AS order_id, o.total_amount
FROM Customers c
JOIN Orders o ON o.customer_id = c.id
WHERE o.order_date = CURRENT_DATE;

How to use CURRENT_DATE in PostgreSQL Syntax


-- Basic usage
CURRENT_DATE

-- In a SELECT
SELECT CURRENT_DATE;

-- In a WHERE filter
SELECT *
FROM Orders
WHERE order_date = CURRENT_DATE;

-- Setting a default value in a table definition
CREATE TABLE Customers (
    id           SERIAL PRIMARY KEY,
    name         TEXT NOT NULL,
    email        TEXT UNIQUE NOT NULL,
    created_at   DATE DEFAULT CURRENT_DATE
);

-- Casting a TIMESTAMP column when comparing
SELECT *
FROM Orders
WHERE order_date::date = CURRENT_DATE;

Common Mistakes

Frequently Asked Questions (FAQs)

Does CURRENT_DATE include the time?

No. It returns only the date part (YYYY-MM-DD), making it ideal for day-level logic.

Is CURRENT_DATE evaluated once per row?

No. PostgreSQL evaluates it once per statement, so every row sees the same value.

Can I replace NOW() with CURRENT_DATE?

Yes, if you need only the date. CURRENT_DATE avoids extra casting and is free from time-zone shifts.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo