How to Get Yesterday’s Date in PostgreSQL Database: PostgreSQL Operators: CURRENT_DATE INTERVAL Table of Contents Problem: Solution 1: Use subtraction Discussion: Solution 2: Use INTERVAL syntax Discussion: Problem: You would like to display yesterday's date (without time) in a PostgreSQL database. Solution 1: Use subtraction SELECT CURRENT_DATE - 1 AS yesterday_date; Assuming today is 2023-09-24, the result is: yesterday_date 2023-09-23 Discussion: To get yesterday's date, you need to subtract one day from today's date. Use CURRENT_DATE to get today's date. Note that you don’t need brackets at the end of the CURRENT_DATE function. In PostgreSQL, you can subtract or add any number of days using the integer substraction. Here, since you need to subtract one day, you use - 1 to get yesterday’s date. Note that the result of this calculation still has the column type date. Solution 2: Use INTERVAL syntax SELECT (CURRENT_DATE - INTERVAL '1 day')::date AS yesterday_date; Assuming today is 2023-09-24, the result is: yesterday_date 2023-09-23 Discussion: Get today's date using CURRENT_DATE. You need to subtract an interval of one day from the current date. To do this, use the INTERVAL keyword, which creates any time/date interval you want (here, '1 day', which in PostgreSQL is the same as 24 hours). Subtracting INTERVAL '1 day' from today's date will result in a column formatted as a timestamp, so you need to cast it to date. The quickest way to do so in PostgreSQL is appending ::date to the whole expression (remember to enclose the expression in parentheses). Of course, you can go back by any time interval just as easily. Here's an example: SELECT (CURRENT_DATE - INTERVAL '3 months 10 days')::date; An INTERVAL can also be added to a date. So, here’s a way if you want to get tomorrow's date: SELECT (CURRENT_DATE + INTERVAL '1 day')::date AS tomorrow_date; Recommended courses: SQL Basics in PostgreSQL Common PostgreSQL Functions SQL Practice Set in PostgreSQL Recommended articles: PostgreSQL Cheat Sheet Standard SQL Functions Cheat Sheet Performing Calculations on Date- and Time-Related Values 18 Useful Important SQL Functions to Learn ASAP SQL Books for Beginners 19 PostgreSQL Practice Exercises with Detailed Solutions Best Books for Learning PostgreSQL PostgreSQL Date Functions See also: How to Extract the Week Number from a Date in PostgreSQL How to Find the Interval Between Two Dates in PostgreSQL How to Get the Day of the Year from a Date in PostgreSQL How to Get the Current Date in PostgreSQL How to Get the Current Time in PostgreSQL How to Get the Current Date and Time (No Time Zone) in PostgreSQL How to Get the Current Date and Time with Time Zone Offset in PostgreSQL How to Convert a String to a Date in PostgreSQL Subscribe to our newsletter Join our monthly newsletter to be notified about the latest posts. Email address How Do You Write a SELECT Statement in SQL? What Is a Foreign Key in SQL? Enumerate and Explain All the Basic Elements of an SQL Query