📅  最后修改于: 2020-12-01 00:54:22             🧑  作者: Mango
与日期和时间相关的所有重要功能的列表:
Function | Description |
---|---|
AGE() | Subtract arguments |
CURRENT DATE/TIME() | It specifies current date and time. |
DATE_PART() | Get subfield (equivalent to extract) |
EXTRACT() | Get subfield. |
ISFINITE() | Test for finite date ,time and interval (not +/-infinity) |
JUSTIFY | Adjust interval |
function | description |
---|---|
age(timestamp, timestamp) | when invoked with the timestamp form of the second argument, age() subtract arguments, producing a “symbolic” result that uses years and months and is of type interval. |
age(timestamp) | when invoked with only the timestamp as argument, age() subtracts from the current_date (at midnight). |
让我们以一个示例检查AGE(timestamp,timestamp)查询为例。
请参阅以下示例:
通过按Ctrl + E打开查询页面。
执行此查询:
SELECT AGE(时间戳'2016-01-26',时间戳'1947-08-15');
它用于产生当前年龄。
执行以下查询:
SELECT AGE(时间戳'1947-08-15');
以下是返回与当前日期和时间相关的值的函数列表。
Function | Description |
---|---|
CURRENT_DATE | Delivers current date. |
CURRENT_TIME | Delivers values with time zone. |
CURRENT_TIMESTAMP | Delivers values with time zone. |
CURRENT_TIME(precision) | Optionally takes a precision parameter, which causes the result to be rounded to that many fractional digits in the seconds field. |
CURRENT_TIMESTAMP(precision) | Optionally takes a precision parameter, which causes the result to be rounded to that many fractional digits in the seconds field. |
LOCALTIME | Delivers values without time zone. |
LOCALTIMESTAMP | Delivers values without time zone. |
LOCALTIME(precision) | Optionally takes a precision parameter, which causes the result to be rounded to that many fractional digits in the seconds field. |
LOCALTIMESTAMP(precision) | Optionally takes a precision parameter, which causes the result to be rounded to that many fractional digits in the seconds field. |
现在,您可以检查以下命令:
当前时间:
SELECT CURRENT_TIME;
对于当前日期:
SELECT CURRENT_DATE;
对于当前时间戳(日期和时间都)
SELECT CURRENT_TIMESTAMP;
当前时间戳更加精确:
SELECT CURRENT_TIMESTAMP(2);
本地时间戳记:
SELECT LOCALTIMESTAMP;