I am trying to get only date without time in postgres from the following statement:
select current_date - date_trunc('day',interval '1 month');
But returns me that:
2023-02-07 00:00:00
What could be going wrong here. I see that date_trunc
function returns timestamp and intervals cannot be cast to date
type:
select current_date - interval '1 month'::date;
>Solution :
You should be able to place the interval
expression into a closure, and then cast that:
select (current_date - interval '1 month')::date; -- 2023-02-07