age(timestamp, timestamp)
| interval | 減去參數後的"符號化"結果,使用年和月,不只是使用天 | age(timestamp '2001-04-10', timestamp '1957-06-13') | 43 years 9 mons 27 days |
age(timestamp) | interval | 從current_date 減去參數後的結果(在午夜) | age(timestamp '1957-06-13') | 43 years 8 mons 3 days |
clock_timestamp()
| timestamp with time zone | 即時時鐘的當前時間戳(在語句執行時變化)
| | |
current_date
| date | 當前的日期;
| | |
current_time
| time with time zone | 當日時間;
| | |
current_timestamp
| timestamp with time zone | 當前事務開始時的時間戳;
| | |
date_part(text, timestamp)
| double precision | 獲取子域(等效於extract );
| date_part('hour', timestamp '2001-02-16 20:38:40') | 20 |
date_part(text, interval) | double precision | 獲取子域(等效於extract );
| date_part('month', interval '2 years 3 months') | 3 |
date_trunc(text, timestamp)
| timestamp | 截斷成指定的精度;
| date_trunc('hour', timestamp '2001-02-16 20:38:40') | 2001-02-16 20:00:00 |
date_trunc(text, interval) | interval | 截取指定的精度,
| date_trunc('hour', interval '2 days 3 hours 40 minutes') | 2 days 03:00:00 |
extract (field from
timestamp)
| double precision | 獲取子域;
| extract(hour from timestamp '2001-02-16 20:38:40') | 20 |
extract (field from
interval) | double precision | 獲取子域;
| extract(month from interval '2 years 3 months') | 3 |
isfinite(date)
| boolean | 測試是否為有窮日期(不是 +/-無窮) | isfinite(date '2001-02-16') | true |
isfinite(timestamp) | boolean | 測試是否為有窮時間戳(不是 +/-無窮) | isfinite(timestamp '2001-02-16 21:28:30') | true |
isfinite(interval) | boolean | 測試是否為有窮時間間隔 | isfinite(interval '4 hours') | true |
justify_days(interval)
| interval | 按照每月 30 天調整時間間隔 | justify_days(interval '35 days') | 1 mon 5 days |
justify_hours(interval)
| interval | 按照每天 24 小時調整時間間隔 | justify_hours(interval '27 hours') | 1 day 03:00:00 |
justify_interval(interval)
| interval | 使用justify_days 和justify_hours 調整時間間隔的同時進行正負號調整 | justify_interval(interval '1 mon -1 hour') | 29 days 23:00:00 |
localtime
| time | 當日時間;
| | |
localtimestamp
| timestamp | 當前事務開始時的時間戳;
| | |
make_date(year int,
month int,
day int)
| date |
為年、月和日字段創建日期
| make_date(2013, 7, 15) | 2013-07-15 |
make_interval(years int DEFAULT 0,
months int DEFAULT 0,
weeks int DEFAULT 0,
days int DEFAULT 0,
hours int DEFAULT 0,
mins int DEFAULT 0,
secs double precision DEFAULT 0.0)
| interval |
從年、月、周、天、小時、分鐘和秒字段中創建間隔
| make_interval(days := 10) | 10 days |
make_time(hour int,
min int,
sec double precision)
| time |
從小時、分鐘和秒字段中創建時間
| make_time(8, 15, 23.5) | 08:15:23.5 |
make_timestamp(year int,
month int,
day int,
hour int,
min int,
sec double precision)
| timestamp |
從年、月、日、小時、分鐘和秒字段中創建時間戳
| make_timestamp(2013, 7, 15, 8, 15, 23.5) | 2013-07-15 08:15:23.5 |
make_timestamptz(year int,
month int,
day int,
hour int,
min int,
sec double precision,
[ timezone text ])
| timestamp with time zone |
從年、月、日、小時、分鐘和秒字段中創建帶有時區的時間戳。
沒有指定timezone時,使用當前的時區。
| make_timestamptz(2013, 7, 15, 8, 15, 23.5) | 2013-07-15 08:15:23.5+01 |
now()
| timestamp with time zone | 當前事務開始時的時間戳;
| | |
statement_timestamp()
| timestamp with time zone | 即時時鐘的當前時間戳;
| | |
timeofday()
| text | 與clock_timestamp 相同,但結果是一個text
字串;
| | |
transaction_timestamp()
| timestamp with time zone | 當前事務開始時的時間戳;
| | |