DATE

Learn how to use the PostgreSQL DATE type to store calendar dates, use date functions like NOW(), AGE(), EXTRACT(), and TO_CHAR(), and set default date values.

5 min read · Last updated: March 2026 · Back to overview

Quick Answer

The PostgreSQL DATE type stores calendar dates (without time) using 4 bytes in yyyy-mm-dd format. It supports a range from 4713 BC to 5874897 AD and works with functions like CURRENT_DATE, AGE(), EXTRACT(), and TO_CHAR() for date arithmetic and formatting.

Spin up a Postgres database in 20 seconds with Vela.

Try Vela Sandbox

The PostgreSQL DATE type stores calendar dates without a time component. It uses 4 bytes and supports dates from 4713 BC to 5874897 AD, stored internally in the yyyy-mm-dd format.

Creating a table with DATE columns

CREATE TABLE employees (
  employee_id SERIAL PRIMARY KEY,
  first_name  VARCHAR(255) NOT NULL,
  last_name   VARCHAR(255) NOT NULL,
  birth_date  DATE NOT NULL,
  hire_date   DATE NOT NULL
);

Use CURRENT_DATE as a default for automatic date stamping:

CREATE TABLE documents (
  document_id  SERIAL PRIMARY KEY,
  header_text  VARCHAR(255) NOT NULL,
  posting_date DATE NOT NULL DEFAULT CURRENT_DATE
);
INSERT INTO documents (header_text) VALUES ('Billing to customer XYZ') RETURNING *;
document_id |       header_text       | posting_date
-------------+-------------------------+--------------
          1 | Billing to customer XYZ | 2024-02-01

Working with date functions

Get the current date:

SELECT CURRENT_DATE;         -- 2024-02-01
SELECT NOW()::date;          -- 2024-02-01

Format a date with TO_CHAR():

SELECT TO_CHAR(CURRENT_DATE, 'dd/mm/yyyy');  -- 01/02/2024
SELECT TO_CHAR(CURRENT_DATE, 'Mon dd, yyyy'); -- Feb 01, 2024

Calculate the interval between two dates:

SELECT
  first_name,
  last_name,
  now() - hire_date AS tenure
FROM employees;
first_name | last_name |           tenure
------------+-----------+---------------------------
Shannon    | Freeman   | 6970 days 08:51:20.824847
Sheila     | Wells     | 7701 days 08:51:20.824847

Calculate age using AGE():

SELECT
  first_name,
  last_name,
  AGE(birth_date) AS age
FROM employees;
first_name | last_name |           age
------------+-----------+--------------------------
Shannon    | Freeman   | 44 years 1 mon
Sheila     | Wells     | 45 years 11 mons 24 days

Extract specific date parts with EXTRACT():

SELECT
  first_name,
  EXTRACT(YEAR  FROM birth_date) AS year,
  EXTRACT(MONTH FROM birth_date) AS month,
  EXTRACT(DAY   FROM birth_date) AS day
FROM employees;
first_name | year | month | day
------------+------+-------+-----
Shannon    | 1980 |     1 |   1
Sheila     | 1978 |     2 |   5

Production tips

  • Use DATE for birth dates, hire dates, and any value where the time component is irrelevant — it is more storage-efficient and semantically clearer than TIMESTAMP.
  • Always store dates in yyyy-mm-dd format in SQL literals — avoid locale-dependent formats like 01/02/2024 which can be ambiguous.
  • Use CURRENT_DATE as a default for event-date columns rather than NOW() to avoid accidentally storing time components.
  • For date range queries, use BETWEEN or >= / < comparisons; both are index-friendly on DATE columns.

Reference: PostgreSQL documentation — Date/Time Types.

Continue in PostgreSQL Data Types: TIMESTAMP.

Related in this section: Boolean · CHAR, VARCHAR, and TEXT · NUMERIC

Frequently Asked Questions

How do I get the current date in PostgreSQL?

Use CURRENT_DATE for just the date: SELECT CURRENT_DATE; Or use NOW()::date to cast the current timestamp to a date: SELECT NOW()::date; Both return the date in yyyy-mm-dd format based on the server timezone.

How do I format a DATE value in PostgreSQL?

Use the TO_CHAR() function with a format template. For example: SELECT TO_CHAR(CURRENT_DATE, 'dd/mm/yyyy'); returns '01/02/2024'. Common patterns include 'YYYY-MM-DD', 'Mon DD, YYYY', 'DD Month YYYY', and 'Day, DD Mon YYYY'.

How do I calculate the difference between two dates?

Subtract one date from another using the minus operator: SELECT hire_date - birth_date AS age_at_hire FROM employees; The result is an integer representing the number of days. For a human-readable interval (years, months, days), use the AGE() function.

What does the AGE() function return in PostgreSQL?

AGE(date) calculates the interval from the given date to the current date, returning years, months, and days. AGE(date1, date2) subtracts date2 from date1. Example: AGE('2024-02-01', '1980-01-01') returns '44 years 1 mon'.

How do I extract year, month, or day from a DATE in PostgreSQL?

Use the EXTRACT() function: EXTRACT(YEAR FROM birth_date), EXTRACT(MONTH FROM birth_date), EXTRACT(DAY FROM birth_date). You can also use date_part('year', birth_date) which is equivalent.