{"Entry":{"collection":"func","key":"date-trunc","name":"date_trunc","aliases":[],"metadata":{"changed_in":["9.4","12","18"],"changes":[{"descriptions_changed":true,"doc_overhaul":false,"from":"7.2","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"7.3"},{"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":false,"from":"9.3","group_changed":null,"signatures":{"added":["date_trunc ( text, interval ) → interval"],"removed":[]},"status":"changed","to":"9.4"},{"descriptions_changed":true,"doc_overhaul":false,"from":"11","group_changed":null,"signatures":{"added":["date_trunc ( text, timestamp with time zone, text ) → timestamp with time zone","date_trunc(field, source [, time_zone ])"],"removed":["date_trunc('field', source)"]},"status":"changed","to":"12"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"},{"descriptions_changed":false,"doc_overhaul":false,"from":"17","group_changed":null,"signatures":{"added":["date_trunc(field, source [, time_zone])"],"removed":["date_trunc(field, source [, time_zone ])"]},"status":"changed","to":"18"}],"content_hash":"abe4b7a175d2444927ab6404d3cef4c40ccaf0165a28414a037e838408acc5f2","first_version":"7.1","group":"datetime","group_label":"Date/Time Functions And Operators","groups":["datetime"],"imported_at":"2026-09-27T17:57:28.529196+08:00","last_version":"20","name":"date_trunc","name_key":"date_trunc","position":8009,"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_trunc ( text, timestamp ) → timestamp","signature_count":4,"slug":"date-trunc","source_rev":"b7bd9cda","summary":"Truncate to specified precision; see Section 9.9.2","summary_zh":""}},"Definition":{"Collection":"func","Key":"date-trunc","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"date-trunc","SourceRevision":"b7bd9cda","Facts":{"description":"Truncate to specified precision; see Section 9.9.2","description_html":"Truncate to specified precision; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003eSection 9.9.2\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":"Truncate to specified precision; see Section 9.9.2","description_html":"Truncate to specified precision; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003eSection 9.9.2\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_trunc('hour', timestamp '2001-02-16 20:38:40')","result":"2001-02-16 20:00:00"}],"html":"\u003ccode class=\"function\"\u003edate_trunc\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etimestamp\u003c/code\u003e","returns":"timestamp","text":"date_trunc ( text, timestamp ) → timestamp","zh_from":""},{"description":"Truncate to specified precision in the specified time zone; see Section 9.9.2","description_html":"Truncate to specified precision in the specified time zone; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003eSection 9.9.2\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_trunc('day', timestamptz '2001-02-16 20:38:40+00', 'Australia/Sydney')","result":"2001-02-16 13:00:00+00"}],"html":"\u003ccode class=\"function\"\u003edate_trunc\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, \u003ccode class=\"type\"\u003etext\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etimestamp with time zone\u003c/code\u003e","returns":"timestamp with time zone","text":"date_trunc ( text, timestamp with time zone, text ) → timestamp with time zone","zh_from":""},{"description":"Truncate to specified precision; see Section 9.9.2","description_html":"Truncate to specified precision; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003eSection 9.9.2\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_trunc('hour', interval '2 days 3 hours 40 minutes')","result":"2 days 03:00:00"}],"html":"\u003ccode class=\"function\"\u003edate_trunc\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003einterval\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einterval\u003c/code\u003e","returns":"interval","text":"date_trunc ( text, interval ) → interval","zh_from":""},{"description":"source is a value expression of type timestamp, timestamp with time zone, or interval. (Values of type date and time are cast automatically to timestamp or interval, respectively.) field selects to which precision to truncate the input value. The return value is likewise of type timestamp, timestamp with time zone, or interval, and it has all fields that are less significant than the selected one set to zero (or one, for day and month).","description_html":"\u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e is a value expression of type \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, or \u003ccode class=\"type\"\u003einterval\u003c/code\u003e. (Values of type \u003ccode class=\"type\"\u003edate\u003c/code\u003e and \u003ccode class=\"type\"\u003etime\u003c/code\u003e are cast automatically to \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e or \u003ccode class=\"type\"\u003einterval\u003c/code\u003e, respectively.) \u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e selects to which precision to truncate the input value. The return value is likewise of type \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, or \u003ccode class=\"type\"\u003einterval\u003c/code\u003e, and it has all fields that are less significant than the selected one set to zero (or one, for day and month).","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003edate_trunc\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 [\u003cspan class=\"optional\"\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime_zone\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e])","returns":"","text":"date_trunc(field, source [, time_zone])","zh_from":""}],"zh_from":""},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-DATETIME-TABLE","file":"functions-datetime.html","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"date-trunc","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"date_trunc","Summary":"截断到指定的精度；参见第 9.9.2 节","BodyHTML":"截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" rel=\"nofollow\"\u003e第 9.9.2 节\u003c/a\u003e\u003cpre\u003edate_trunc ( text, timestamp ) → timestamp\u003c/pre\u003e截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" rel=\"nofollow\"\u003e第 9.9.2 节\u003c/a\u003e\u003cpre\u003edate_trunc ( text, timestamp with time zone, text ) → timestamp with time zone\u003c/pre\u003e在规定的时区中截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" rel=\"nofollow\"\u003e第 9.9.2 节\u003c/a\u003e\u003cpre\u003edate_trunc ( text, interval ) → interval\u003c/pre\u003e截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" rel=\"nofollow\"\u003e第 9.9.2 节\u003c/a\u003e\u003cpre\u003edate_trunc(field, source [, time_zone])\u003c/pre\u003e\u003cem\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e是\u003ccode\u003etimestamp\u003c/code\u003e、\u003ccode\u003etimestamp with time zone\u003c/code\u003e或\u003ccode\u003einterval\u003c/code\u003e类型的值表达式。（\u003ccode\u003edate\u003c/code\u003e和\u003ccode\u003etime\u003c/code\u003e类型的值会分别自动转换为\u003ccode\u003etimestamp\u003c/code\u003e或\u003ccode\u003einterval\u003c/code\u003e。）\u003cem\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e选择输入值的截断精度。返回值同样为\u003ccode\u003etimestamp\u003c/code\u003e、\u003ccode\u003etimestamp with time zone\u003c/code\u003e或\u003ccode\u003einterval\u003c/code\u003e类型，其中低于所选精度的所有字段都设为零（日和月则设为一）。","SourceRevision":"1b5ca64c","ContentHash":"d8da135295ed19569fa6776a206cfa434ef8259bc6326c7123409adcc35ff110","Payload":{"description_zh":"截断到指定的精度；参见第 9.9.2 节","description_zh_html":"截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003e第 9.9.2 节\u003c/a\u003e","signatures":[{"description_zh":"截断到指定的精度；参见第 9.9.2 节","description_zh_html":"截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003e第 9.9.2 节\u003c/a\u003e","returns":"timestamp","text":"date_trunc ( text, timestamp ) → timestamp","zh_from":"doc"},{"description_zh":"在规定的时区中截断到指定的精度；参见第 9.9.2 节","description_zh_html":"在规定的时区中截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003e第 9.9.2 节\u003c/a\u003e","returns":"timestamp with time zone","text":"date_trunc ( text, timestamp with time zone, text ) → timestamp with time zone","zh_from":"doc"},{"description_zh":"截断到指定的精度；参见第 9.9.2 节","description_zh_html":"截断到指定的精度；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003e第 9.9.2 节\u003c/a\u003e","returns":"interval","text":"date_trunc ( text, interval ) → interval","zh_from":"doc"},{"description_zh":"source是timestamp、timestamp with time zone或interval类型的值表达式。（date和time类型的值会分别自动转换为timestamp或interval。）field选择输入值的截断精度。返回值同样为timestamp、timestamp with time zone或interval类型，其中低于所选精度的所有字段都设为零（日和月则设为一）。","description_zh_html":"\u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e是\u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e、\u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e或\u003ccode class=\"type\"\u003einterval\u003c/code\u003e类型的值表达式。（\u003ccode class=\"type\"\u003edate\u003c/code\u003e和\u003ccode class=\"type\"\u003etime\u003c/code\u003e类型的值会分别自动转换为\u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e或\u003ccode class=\"type\"\u003einterval\u003c/code\u003e。）\u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e选择输入值的截断精度。返回值同样为\u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e、\u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e或\u003ccode class=\"type\"\u003einterval\u003c/code\u003e类型，其中低于所选精度的所有字段都设为零（日和月则设为一）。","returns":"","text":"date_trunc(field, source [, time_zone])","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":"e69ae7c9244301c111d5637a94dfa1ff22b88711e81f8e45a4836bdfc05bcebe","Text":"date_trunc ( text, timestamp ) → timestamp","Returns":"timestamp","Payload":{"description":"Truncate to specified precision; see Section 9.9.2","description_html":"Truncate to specified precision; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003eSection 9.9.2\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_trunc('hour', timestamp '2001-02-16 20:38:40')","result":"2001-02-16 20:00:00"}],"html":"\u003ccode class=\"function\"\u003edate_trunc\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etimestamp\u003c/code\u003e","returns":"timestamp","text":"date_trunc ( text, timestamp ) → timestamp","zh_from":""}},{"Version":"18","Ordinal":1,"Hash":"8dc36a58c31761d131b688542890787655b685348ca10bb729cf0134bb3440e7","Text":"date_trunc ( text, timestamp with time zone, text ) → timestamp with time zone","Returns":"timestamp with time zone","Payload":{"description":"Truncate to specified precision in the specified time zone; see Section 9.9.2","description_html":"Truncate to specified precision in the specified time zone; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003eSection 9.9.2\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_trunc('day', timestamptz '2001-02-16 20:38:40+00', 'Australia/Sydney')","result":"2001-02-16 13:00:00+00"}],"html":"\u003ccode class=\"function\"\u003edate_trunc\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, \u003ccode class=\"type\"\u003etext\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etimestamp with time zone\u003c/code\u003e","returns":"timestamp with time zone","text":"date_trunc ( text, timestamp with time zone, text ) → timestamp with time zone","zh_from":""}},{"Version":"18","Ordinal":2,"Hash":"feb5b4f1af75550faac53dc09777ed8d3533851cb64ec499cb5b2cec267cbc3c","Text":"date_trunc ( text, interval ) → interval","Returns":"interval","Payload":{"description":"Truncate to specified precision; see Section 9.9.2","description_html":"Truncate to specified precision; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC\" title=\"9.9.2. date_trunc\"\u003eSection 9.9.2\u003c/a\u003e","description_zh":"","description_zh_html":"","examples":[{"expr":"date_trunc('hour', interval '2 days 3 hours 40 minutes')","result":"2 days 03:00:00"}],"html":"\u003ccode class=\"function\"\u003edate_trunc\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003ccode class=\"type\"\u003einterval\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einterval\u003c/code\u003e","returns":"interval","text":"date_trunc ( text, interval ) → interval","zh_from":""}},{"Version":"18","Ordinal":3,"Hash":"1a6b8950a6226db039c3abbbda56387ce165547807e6da3e65204745cb5eec7c","Text":"date_trunc(field, source [, time_zone])","Returns":"","Payload":{"description":"source is a value expression of type timestamp, timestamp with time zone, or interval. (Values of type date and time are cast automatically to timestamp or interval, respectively.) field selects to which precision to truncate the input value. The return value is likewise of type timestamp, timestamp with time zone, or interval, and it has all fields that are less significant than the selected one set to zero (or one, for day and month).","description_html":"\u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e is a value expression of type \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, or \u003ccode class=\"type\"\u003einterval\u003c/code\u003e. (Values of type \u003ccode class=\"type\"\u003edate\u003c/code\u003e and \u003ccode class=\"type\"\u003etime\u003c/code\u003e are cast automatically to \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e or \u003ccode class=\"type\"\u003einterval\u003c/code\u003e, respectively.) \u003cem class=\"replaceable\"\u003e\u003ccode\u003efield\u003c/code\u003e\u003c/em\u003e selects to which precision to truncate the input value. The return value is likewise of type \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, or \u003ccode class=\"type\"\u003einterval\u003c/code\u003e, and it has all fields that are less significant than the selected one set to zero (or one, for day and month).","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003edate_trunc\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 [\u003cspan class=\"optional\"\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime_zone\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e])","returns":"","text":"date_trunc(field, source [, time_zone])","zh_from":""}}],"Spellings":null,"SQLState":null,"Evidence":null}
