How to use CURRENT_DATE in PostgreSQL

Galaxy Glossary

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

CURRENT_DATE returns the current session-timezone date as a value of type date.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

What does CURRENT_DATE return?

CURRENT_DATE yields the calendar date based on the session’s time zone, with the data type date. It contains no time-of-day component, so comparisons and formatting are straightforward.

How do I get today’s date in a query?

Run SELECT CURRENT_DATE; to see today’s date. In a script, assign an alias for clarity: SELECT CURRENT_DATE AS today;.

What is the exact syntax of CURRENT_DATE?

CURRENT_DATE is a SQL standard special register—no parentheses needed. You can optionally cast or alias it. See full syntax below.

Can I filter rows using CURRENT_DATE?

Yes. Use it in WHERE clauses to fetch records created today: ... WHERE created_at::date = CURRENT_DATE.

How do I offset the current date?

Add or subtract intervals: CURRENT_DATE + INTERVAL '7 days' returns the date one week ahead; subtract for past dates.

Does CURRENT_DATE respect my time zone?

It reflects the session time zone. Execute SHOW TIME ZONE; or set one with SET TIME ZONE 'America/New_York'; before calling CURRENT_DATE.

Best practices for CURRENT_DATE

Cast timestamp columns to date before comparison, index created_at when filtering by date, and avoid wrapping CURRENT_DATE in functions that prevent index use.

Why How to use CURRENT_DATE in PostgreSQL is important

How to use CURRENT_DATE in PostgreSQL Example Usage


-- Retrieve today’s orders and customer info
SELECT o.id,
       c.name,
       o.total_amount
FROM Orders AS o
JOIN Customers AS c ON c.id = o.customer_id
WHERE o.order_date = CURRENT_DATE
ORDER BY o.total_amount DESC;

How to use CURRENT_DATE in PostgreSQL Syntax


-- Basic
SELECT CURRENT_DATE;

-- Alias for readability
SELECT CURRENT_DATE AS today;

-- Use in WHERE clause (ecommerce example)
SELECT *
FROM Orders
WHERE order_date = CURRENT_DATE;

-- Offset by interval
SELECT CURRENT_DATE + INTERVAL '1 day'  AS tomorrow;

-- Assign to variable (plpgsql)
DECLARE
    report_date date := CURRENT_DATE;
BEGIN
    -- logic here
END;

Common Mistakes

Frequently Asked Questions (FAQs)

Is CURRENT_DATE the same as NOW()?

No. NOW() (or CURRENT_TIMESTAMP) returns a timestamp with date and time. CURRENT_DATE returns only the date portion.

Does CURRENT_DATE change mid-transaction?

No. Its value is fixed at the start of the transaction, ensuring consistency across statements.

How can I get the UTC current date?

Temporarily set the session time zone: SET TIME ZONE 'UTC'; SELECT CURRENT_DATE;. Remember to reset it afterward if needed.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.