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 | 当前事务开始时的时间戳; |
|
|