PostgreSQL - DATEDIFF - Datetime Difference in Seconds, Days, Months, Weeks etc - SQLines

PHOTO EMBED

Fri Apr 30 2021 16:45:24 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

  -- Difference between Oct 02, 2011 and Jan 01, 2012 in years
  SELECT DATE_PART('year', '2012-01-01'::date) - DATE_PART('year', '2011-10-02'::date);
  -- Result: 1
content_copyCOPY

https://www.sqlines.com/postgresql/how-to/datediff