Home > database >  PGSQL acquisition date
PGSQL acquisition date

Time:09-17

PGSQL for current date last month on the first day and last day


About the grammar of the PGSQL, what is the recommended books? To Chinese, thank you.

CodePudding user response:

You consult:
The current date on the first day of the month: date_trunc (' month ', current_date)
Date of the increase and decrease, current_date - interval '1 day, the day before the current date
Current_date - interval '1 month - the current date of last month, the day

The first day of the last day of that month=next month - 1 day

CodePudding user response:

http://www.postgres.cn/index.php/v2/home

Postgresql Chinese website, look at the help documentation

CodePudding user response:

The select current_date as the current date
, date_trunc (' month ', current_date) as the first day of that month
, date_trunc (' year ', current_date) as the first day
, date_trunc (' month ', current_date) - interval '1 up as the first day of the month
, date_trunc (' month ', current_date) - interval '1 days as last month, the last day

CodePudding user response:

Thank you all!!!!!
  • Related