What are common date/time functions in PostgreSQL?

Answer

PostgreSQL's date/time capabilities are excellent. Current time: NOW() (transaction time, with timezone), CURRENT_TIMESTAMP (same as NOW), CLOCK_TIMESTAMP() (actual wall-clock time), CURRENT_DATE, CURRENT_TIME. Extract parts: EXTRACT(YEAR FROM timestamp), DATE_PART('month', timestamp). Arithmetic: NOW() - INTERVAL '7 days', date1 - date2 (returns interval). Truncate: DATE_TRUNC('month', timestamp) — truncates to start of month. Format: TO_CHAR(NOW(), 'YYYY-MM-DD HH24:MI'). Parse: TO_TIMESTAMP('2024-01-15', 'YYYY-MM-DD'). Age: AGE(timestamp) returns interval from date to now. Always store timestamps as TIMESTAMPTZ (with timezone) to avoid timezone confusion.