Funktionen zur Datenbearbeitung in PostgreSQL
Brian Piccolo
Sr. Director, Digital Strategy
CURRENT_DATE, CURRENT_TIMESTAMP und NOW()AGE()EXTRACT(), DATE_PART() und DATE_TRUNC()SELECT date '2005-09-11' - date '2005-09-10';+---------+ | integer | |---------| | 1 | +---------+
SELECT date '2005-09-11' + integer '3';+------------+ | date | |------------| | 2005-09-14 | +------------+
SELECT date '2005-09-11 00:00:00' - date '2005-09-09 12:00:00';+----------------+ | interval | |----------------| | 1 day 12:00:00 | +----------------+
SELECT AGE(timestamp '2005-09-11 00:00:00', timestamp '2005-09-09 12:00:00');+----------------+ | interval | |----------------| | 1 day 12:00:00 | +----------------+
SELECT AGE(rental_date) FROM rental;+-----------------------------------+ | age | |-----------------------------------| | 13 years 11 mons 12 days 01:06:30 | | 13 years 11 mons 12 days 01:05:27 | | 13 years 11 mons 12 days 00:56:21 | +-----------------------------------+
SELECT rental_date + INTERVAL '3 days' as expected_return FROM rental;+---------------------+ | expected_return | |---------------------| | 2005-05-27 22:53:30 | +---------------------+
SELECT timestamp '2019-05-01' + 21 * INTERVAL '1 day';+----------------------------+ | timestamp without timezone | |----------------------------| | 2019-05-22 00:00:00 | +----------------------------+
Funktionen zur Datenbearbeitung in PostgreSQL