function | return type | describe | example | result |
---|---|---|---|---|
age(timestamp, timestamp) |
interval | "Symbolicized" result after subtracting arguments, using years and months, not just days | age(timestamp '2001-04-10', timestamp '1957-06-13') | 43 years 9 mons 27 days |
age(timestamp) |
interval | From current_date the result after subtracting the argument (at midnight) |
age(timestamp '1957-06-13') | 43 years 8 mons 3 days |
clock_timestamp() |
timestamp with time zone | The current timestamp of the real-time clock (changes as the statement executes) | ||
current_date |
date | the current date; | ||
current_time |
time with time zone | time of day; | ||
current_timestamp |
timestamp with time zone | Timestamp when the current transaction started; | ||
date_part(text, timestamp) |
double precision | get subdomain (equivalent to extract ); |
date_part('hour', timestamp '2001-02-16 20:38:40') | 20 |
date_part(text, interval) |
double precision | get subdomain (equivalent to extract ); |
date_part('month', interval '2 years 3 months') | 3 |
date_trunc(text, timestamp) |
timestamp | truncate to the specified precision; | date_trunc('hour', timestamp '2001-02-16 20:38:40') | 2001-02-16 20:00:00 |
date_trunc(text, interval) |
interval | intercept to the specified precision, | date_trunc('hour', interval '2 days 3 hours 40 minutes') | 2 days 03:00:00 |
extract (field from timestamp) |
double precision | get subdomain; | extract(hour from timestamp '2001-02-16 20:38:40') | 20 |
extract (field from interval) |
double precision | get subdomain; | extract(month from interval '2 years 3 months') | 3 |
isfinite(date) |
boolean | Test for finite date (not +/- infinite) | isfinite(date '2001-02-16') | true |
isfinite(timestamp) |
boolean | Test for finite timestamps (not +/- infinity) | isfinite(timestamp '2001-02-16 21:28:30') | true |
isfinite(interval) |
boolean | test whether it is a finite time interval | isfinite(interval '4 hours') | true |
justify_days(interval) |
interval | Adjust the time interval by 30 days per month | justify_days(interval '35 days') | 1 mon 5 days |
justify_hours(interval) |
interval | Adjust the time interval according to 24 hours a day | justify_hours(interval '27 hours') | 1 day 03:00:00 |
justify_interval(interval) |
interval | Sign adjustments while using justify_days and adjusting time intervalsjustify_hours |
justify_interval(interval '1 mon -1 hour') | 29 days 23:00:00 |
localtime |
time | time of day; | ||
localtimestamp |
timestamp | Timestamp when the current transaction started; | ||
make_date(year int, month int, day int) |
date | Create a date for the year, month and day fields | 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 | Create intervals from year, month, week, day, hour, minute and second fields | make_interval(days := 10) | 10 days |
make_time(hour int, min int, sec double precision) |
time | Create time from hours, minutes and seconds fields | 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 | Create timestamps from year, month, day, hour, minute and second fields | 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 | Create a timestamp with time zone from the year, month, day, hour, minute and second fields. When no timezone is specified, the current timezone is used. | 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 | 当前事务开始时的时间戳; |
PostgreSQL time/date functions
Guess you like
Origin blog.csdn.net/yeyaozhifengqi/article/details/130344310
Ranking