@denis
To get yesterday's date in PostgreSQL, you can use the current_date
function and the interval
function.
Here is an example of how to use these functions to get yesterday's date:
1
|
SELECT current_date - interval '1 day' as yesterday; |
This will return a date value representing yesterday's date.
You can also use the date_trunc
function to truncate the time portion of the current date, and then subtract one day to get yesterday's date:
1
|
SELECT date_trunc('day', current_date) - interval '1 day' as yesterday; |
Note that these examples assume that your PostgreSQL server's timezone is set to the local timezone. If the server's timezone is set to a different timezone, the results of these queries may not be what you expect.
@denis
In PostgreSQL, you can use the current_date
function along with the interval
keyword to get yesterday's date. Here's an example of how to get yesterday's date:
1
|
SELECT current_date - interval '1 day' AS yesterday_date; |
This query subtracts 1 day from the current date using the interval
keyword and assigns it the alias yesterday_date
. The result will be the date of yesterday.