{"Entry":{"collection":"func","key":"date-part","name":"date_part","aliases":[],"metadata":{"changed_in":[],"changes":[{"descriptions_changed":true,"doc_overhaul":false,"from":"7.3","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"7.4"},{"descriptions_changed":true,"doc_overhaul":false,"from":"7.4","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"8.0"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"}],"content_hash":"4a57e5abff76cc2b504b32d8c055de34b4e9c902768bbf8ff010010c568f263c","first_version":"7.1","group":"datetime","group_label":"Date/Time Functions And Operators","groups":["datetime"],"imported_at":"2026-09-27T17:57:28.524383+08:00","last_version":"20","name":"date_part","name_key":"date_part","position":8007,"present_in":["7.1","7.2","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"signature":"date_part ( text, timestamp ) → double precision","signature_count":3,"slug":"date-part","source_rev":"b7bd9cda","summary":"Get timestamp subfield (equivalent to extract); see Section 9.9.1","summary_zh":""}},"Definition":{"Collection":"func","Key":"date-part","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"date-part","SourceRevision":"b7bd9cda","Facts":{"description":"Get timestamp subfield (equivalent to extract); see Section 9.9.1","description_html":"Get timestamp subfield (equivalent to \u003ccode class=\"function\"\u003eextract\u003c/code\u003e); see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003eSection 9.9.1\u003c/a\u003e","description_zh":"","description_zh_html":"","doc":{"anchor":"FUNCTIONS-DATETIME-TABLE","file":"functions-datetime.html","slug":"18"},"group":"datetime","group_label":"Date/Time Functions And Operators","lang":"en","layout":"table-new","pages":["functions-datetime.html"],"prose_only":false,"signatures":[{"description":"Get timestamp subfield (equivalent to extract); see Section 9.9.1","description_html":"Get timestamp subfield (equivalent to \u003ccode class=\"function\"\u003eextract\u003c/code\u003e); see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003eSection 9.9.1\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_part('hour', timestamp '2001-02-16 20:38:40')","result":"20"}],"html":"\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble precision\u003c/code\u003e","returns":"double precision","text":"date_part ( text, timestamp ) → double precision","zh_from":""},{"description":"Get interval subfield (equivalent to extract); see Section 9.9.1","description_html":"Get interval subfield (equivalent to \u003ccode class=\"function\"\u003eextract\u003c/code\u003e); see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003eSection 9.9.1\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_part('month', interval '2 years 3 months')","result":"3"}],"html":"\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003einterval\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble precision\u003c/code\u003e","returns":"double precision","text":"date_part ( text, interval ) → double precision","zh_from":""},{"description":"Note that here the field parameter needs to be a string value, not a name. The valid field names for date_part are the same as for extract. For historical reasons, the date_part function returns values of type double precision. This can result in a loss of precision in certain uses. Using extract is recommended instead.","description_html":"Note that here the \u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e parameter needs to be a string value, not a name. The valid field names for \u003ccode class=\"function\"\u003edate_part\u003c/code\u003e are the same as for \u003ccode class=\"function\"\u003eextract\u003c/code\u003e. For historical reasons, the \u003ccode class=\"function\"\u003edate_part\u003c/code\u003e function returns values of type \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e. This can result in a loss of precision in certain uses. Using \u003ccode class=\"function\"\u003eextract\u003c/code\u003e is recommended instead.","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e('\u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e', \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e)","returns":"","text":"date_part('field', source)","zh_from":""}],"zh_from":""},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-DATETIME-TABLE","file":"functions-datetime.html","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"date-part","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"date_part","Summary":"获取时间戳子字段（等同于 extract）；参见第 9.9.1 节","BodyHTML":"获取时间戳子字段（等同于 \u003ccode\u003eextract\u003c/code\u003e）；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" rel=\"nofollow\"\u003e第 9.9.1 节\u003c/a\u003e\u003cpre\u003edate_part ( text, timestamp ) → double precision\u003c/pre\u003e获取时间戳子字段（等同于 \u003ccode\u003eextract\u003c/code\u003e）；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" rel=\"nofollow\"\u003e第 9.9.1 节\u003c/a\u003e\u003cpre\u003edate_part ( text, interval ) → double precision\u003c/pre\u003e获取时间间隔子字段（等同于 \u003ccode\u003eextract\u003c/code\u003e）；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" rel=\"nofollow\"\u003e第 9.9.1 节\u003c/a\u003e\u003cpre\u003edate_part(\u0026#39;field\u0026#39;, source)\u003c/pre\u003e注意，此处的\u003cem\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e参数必须是字符串值，而不能是名称。\u003ccode\u003edate_part\u003c/code\u003e的有效字段名与\u003ccode\u003eextract\u003c/code\u003e相同。由于历史原因，\u003ccode\u003edate_part\u003c/code\u003e函数返回\u003ccode\u003edouble precision\u003c/code\u003e类型的值，可能在某些用途中损失精度。建议改用\u003ccode\u003eextract\u003c/code\u003e。","SourceRevision":"ca936764","ContentHash":"09933bc778e8e7a9824d6907a654ef5809e551a4f5c096a2887dd0404fcec0ce","Payload":{"description_zh":"获取时间戳子字段（等同于 extract）；参见第 9.9.1 节","description_zh_html":"获取时间戳子字段（等同于 \u003ccode class=\"function\"\u003eextract\u003c/code\u003e）；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003e第 9.9.1 节\u003c/a\u003e","signatures":[{"description_zh":"获取时间戳子字段（等同于 extract）；参见第 9.9.1 节","description_zh_html":"获取时间戳子字段（等同于 \u003ccode class=\"function\"\u003eextract\u003c/code\u003e）；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003e第 9.9.1 节\u003c/a\u003e","returns":"double precision","text":"date_part ( text, timestamp ) → double precision","zh_from":"doc"},{"description_zh":"获取时间间隔子字段（等同于 extract）；参见第 9.9.1 节","description_zh_html":"获取时间间隔子字段（等同于 \u003ccode class=\"function\"\u003eextract\u003c/code\u003e）；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003e第 9.9.1 节\u003c/a\u003e","returns":"double precision","text":"date_part ( text, interval ) → double precision","zh_from":"doc"},{"description_zh":"注意，此处的field参数必须是字符串值，而不能是名称。date_part的有效字段名与extract相同。由于历史原因，date_part函数返回double precision类型的值，可能在某些用途中损失精度。建议改用extract。","description_zh_html":"注意，此处的\u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e参数必须是字符串值，而不能是名称。\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e的有效字段名与\u003ccode class=\"function\"\u003eextract\u003c/code\u003e相同。由于历史原因，\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e函数返回\u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e类型的值，可能在某些用途中损失精度。建议改用\u003ccode class=\"function\"\u003eextract\u003c/code\u003e。","returns":"","text":"date_part('field', source)","zh_from":"doc"}],"zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.1","7.2","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"435390a2d3ae8746f5ae9ab24262bb15a9bfbf9a7c77259d30b4345079146e79","Text":"date_part ( text, timestamp ) → double precision","Returns":"double precision","Payload":{"description":"Get timestamp subfield (equivalent to extract); see Section 9.9.1","description_html":"Get timestamp subfield (equivalent to \u003ccode class=\"function\"\u003eextract\u003c/code\u003e); see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003eSection 9.9.1\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_part('hour', timestamp '2001-02-16 20:38:40')","result":"20"}],"html":"\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble precision\u003c/code\u003e","returns":"double precision","text":"date_part ( text, timestamp ) → double precision","zh_from":""}},{"Version":"18","Ordinal":1,"Hash":"92f49f2cac6bedf5de10a2a3125638ffbd7781b66dfc08be9ca8268e8f79207d","Text":"date_part ( text, interval ) → double precision","Returns":"double precision","Payload":{"description":"Get interval subfield (equivalent to extract); see Section 9.9.1","description_html":"Get interval subfield (equivalent to \u003ccode class=\"function\"\u003eextract\u003c/code\u003e); see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT\" title=\"9.9.1. EXTRACT, date_part\"\u003eSection 9.9.1\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_part('month', interval '2 years 3 months')","result":"3"}],"html":"\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003einterval\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble precision\u003c/code\u003e","returns":"double precision","text":"date_part ( text, interval ) → double precision","zh_from":""}},{"Version":"18","Ordinal":2,"Hash":"0ca9762e406fc114f7186b63eaa766591783498483f242cffeeb75b6b5b38bf0","Text":"date_part('field', source)","Returns":"","Payload":{"description":"Note that here the field parameter needs to be a string value, not a name. The valid field names for date_part are the same as for extract. For historical reasons, the date_part function returns values of type double precision. This can result in a loss of precision in certain uses. Using extract is recommended instead.","description_html":"Note that here the \u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e parameter needs to be a string value, not a name. The valid field names for \u003ccode class=\"function\"\u003edate_part\u003c/code\u003e are the same as for \u003ccode class=\"function\"\u003eextract\u003c/code\u003e. For historical reasons, the \u003ccode class=\"function\"\u003edate_part\u003c/code\u003e function returns values of type \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e. This can result in a loss of precision in certain uses. Using \u003ccode class=\"function\"\u003eextract\u003c/code\u003e is recommended instead.","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003edate_part\u003c/code\u003e('\u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e', \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e)","returns":"","text":"date_part('field', source)","zh_from":""}}],"Spellings":null,"SQLState":null,"Evidence":null}
