添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
时尚的蜡烛  ·  AWS DMS 数据验证 - AWS ...·  3 月前    · 
谈吐大方的斑马  ·  发布记录 | MogDB Docs·  3 月前    · 
失望的斑马  ·  数据库准备 | Gitea ...·  2 月前    · 
道上混的领结  ·  Postgresql Error ...·  1 月前    · 
高大的茶壶  ·  Losing progress on ...·  1 月前    · 
大力的西瓜  ·  Unsupported lookup ...·  1 年前    · 
善良的香烟  ·  java blob转base64_JAVA ...·  2 年前    · 

date_part() is a system function for retrieving elements of a date or timestamp, similar to extract() .

date_part() was added in PostgreSQL 6.1 .

Usage

date_part(field text, source date) → double precision
date_part(field text, source interval) → double precision
date_part(field text, source timestamp) → double precision
date_part(field text, source timestamp with time zone) → double precision

date_part() does essentially the same thing as the SQL-standard extract() function, and was originally intended to provide Ingres compatibility. From PostgreSQL 14 it is recommended to use extract() , as that function now returns numeric , whereas the double precision value returned by date_part() and extract() (prior to PostgreSQL 14 ) can result in a loss of precision in certain cases.

Change history

  • PostgreSQL 6.1
  • added (commit 2ab34dfe )
  • (1 row)

    In PostgreSQL 14 and later, the value returned by date_part() may not be identical to the one returned by extract() :

    postgres=# WITH now AS (
      SELECT NOW() AS now
    SELECT date_part('epoch', now.now), extract('epoch' FROM now.now)
      FROM now;
        date_part     |      extract      
    ------------------+-------------------
     1637913804.90921 | 1637913804.909210
    (1 row)