make_timestamp()

一个用于从单个值创建时间戳的函数

make_timestamp() 是一个系统函数,用于根据提供的年、月、日、时、分和秒来组合一个 timestamp 值。

make_timestamp()PostgreSQL 9.4 中被添加。

用法

make_timestamp ( year int, month int, day int, hour int, min int, sec double precision ) → timestamp

必须提供所有参数。

如果提供的任何参数无效,则会引发错误。

变更历史

示例

make_timestamp() 的基本用法示例

postgres=# SELECT make_timestamp(2021,8,29,23,10,56.32);
     make_timestamp
------------------------
 2021-08-29 23:10:56.32
(1 row)

提供一个或多个无效的日期参数

postgres=# SELECT make_timestamp(2021,13,29,23,10,11.22);
ERROR:  date field value out of range: 2021-13-29

提供一个或多个无效的时间参数

postgres=# SELECT make_timestamp(2021,8,29,25,10,99.32);
ERROR:  time field value out of range: 25:10:99.32

分类

日期和时间, 系统函数

另请参阅

make_date(), make_time(), make_timestamptz(), make_interval()

反馈

提交关于“make_timestamp()”的任何评论、建议或更正,请在此处 提交