postgresql 取日期的函数
目录
1.获取日期时间的方法
2. 获取两个时间点内每个月第一天的日期
3.获取当前日期所在月份的第一天
4.获取两个时间点内每天的日期
5.获取前1的天的日期
1.获取日期时间的方法
获取当前事务的日期和/或时间∶
CURRENT_DATE
CURRENT_TIME
CURRENT_TIME (precision)
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP (precision)
LOCALTIME
LOCALTIME (precision)
LOCALTIMESTAMP
LOCALTIMESTAMP (precision)
now()
transaction_timestamp()
$ psql
psql (9.1.24)
Type “help” for help.
postgres=# select now();
now
2018-07-25 11:15:26.238933+08
(1 row)
postgres=# begin;
BEGIN
postgres=# \x
Expanded display is on.
postgres=# select current_date,
current_time,
current_time(6),
current_timestamp,
current_timestamp(6),
localtime,
localtime(6),
localtimestamp,
localtimestamp(6),
now(),