{"Entry":{"collection":"func","key":"date-bin","name":"date_bin","aliases":[],"metadata":{"changed_in":[],"changes":[{"descriptions_changed":false,"doc_overhaul":false,"from":"13","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"added","to":"14"}],"content_hash":"a0c39e7544aa0b56fb1ed63038e6511d9f18a81d058faf02228a7ca24b227d79","derived_content_hash":"6155362a5ec58e30b026cb892c08b65fec1e7eaed3d83e65534202e91b47ea51","documentation_refresh":{"batch":"20261113","original_source_rev":"wiki-repair-20261023:eb2fc95fdc5365ead48ba5b3c28cfc1f3be26f8313172639c558d9f13749192f","versions":{"14":"14.25","15":"15.20","16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"first_version":"14","group":"datetime","group_label":"Date/Time Functions And Operators","groups":["datetime"],"imported_at":"2026-09-14T21:49:48.697746+08:00","last_version":"20","name":"date_bin","name_key":"date_bin","position":8006,"present_in":["14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"2026-09-14T13:14:25.684213+00:00@99e6866c","receipt_sha256":"f638b406d4bd541e5142cef5cdcf46f7da29a76c157d7e9ff9b5810fac92f9fd","repair":"wiki-repair-20261023"},"signature":"date_bin ( interval, timestamp, timestamp ) → timestamp","signature_count":2,"slug":"date-bin","source_rev":"wiki-repair-20261023:eb2fc95fdc5365ead48ba5b3c28cfc1f3be26f8313172639c558d9f13749192f","summary":"Bin input into specified interval aligned with specified origin; see Section 9.9.3","summary_zh":""}},"Definition":{"Collection":"func","Key":"date-bin","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"date-bin","SourceRevision":"wiki-repair-20261023:eb2fc95fdc5365ead48ba5b3c28cfc1f3be26f8313172639c558d9f13749192f","Facts":{"description":"Bin input into specified interval aligned with specified origin; see Section 9.9.3","description_html":"Bin input into specified interval aligned with specified origin; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003eSection 9.9.3\u003c/a\u003e","description_zh":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见第 9.9.3 节","description_zh_html":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003e第 9.9.3 节\u003c/a\u003e","doc":{"anchor":"FUNCTIONS-DATETIME-TABLE","file":"functions-datetime.html","sha256":"8c5053713aeaacfbe4cb00effc61f10d457c98b2a29c724b10b93819a087ea95","slug":"18"},"documentation_revision":{"inputs":[{"file":"functions-datetime.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"8c5053713aeaacfbe4cb00effc61f10d457c98b2a29c724b10b93819a087ea95","version":"18.7"},{"file":"functions-datetime.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"c3efdd1c3df6795c73dfea2ecec17ca31ff37da23d758083a581d75445851f0c","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"},"group":"datetime","group_label":"时间/日期函数和操作符","lang":"en","layout":"table-new","pages":["functions-datetime.html"],"prose_only":false,"signatures":[{"description":"Bin input into specified interval aligned with specified origin; see Section 9.9.3","description_html":"Bin input into specified interval aligned with specified origin; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003eSection 9.9.3\u003c/a\u003e","description_zh":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见第 9.9.3 节","description_zh_html":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003e第 9.9.3 节\u003c/a\u003e","examples":[{"expr":"date_bin('15 minutes', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00')","result":"2001-02-16 20:35:00"}],"html":"\u003ccode class=\"function\"\u003edate_bin\u003c/code\u003e ( \u003ccode class=\"type\"\u003einterval\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etimestamp\u003c/code\u003e","returns":"timestamp","text":"date_bin ( interval, timestamp, timestamp ) → timestamp","zh_from":"same-version-manual"},{"description":"source is a value expression of type timestamp or timestamp with time zone. (Values of type date are cast automatically to timestamp.) stride is a value expression of type interval. The return value is likewise of type timestamp or timestamp with time zone, and it marks the beginning of the bin into which the source is placed.","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 or \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e. (Values of type \u003ccode class=\"type\"\u003edate\u003c/code\u003e are cast automatically to \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e.) \u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e is a value expression of type \u003ccode class=\"type\"\u003einterval\u003c/code\u003e. The return value is likewise of type \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e or \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, and it marks the beginning of the bin into which the \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e is placed.","description_zh":"source 是 timestamp 或 timestamp with time zone 类型的值表达式。（类型 date 的值会自动转换为 timestamp。）stride 是 interval 类型的值表达式。返回值同样是 timestamp 或 timestamp with time zone 类型，并且它表示 source 所在分箱的起点。","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\"\u003edate\u003c/code\u003e 的值会自动转换为 \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e。）\u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e 是 \u003ccode class=\"type\"\u003einterval\u003c/code\u003e 类型的值表达式。返回值同样是 \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e 或 \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e 类型，并且它表示 \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e 所在分箱的起点。","examples":[],"html":"\u003ccode class=\"function\"\u003edate_bin\u003c/code\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eorigin\u003c/code\u003e\u003c/em\u003e)","returns":"","text":"date_bin(stride, source, origin)","zh_from":"same-version-manual"}],"translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/functions-datetime.html","sha256":"2340eed8f18e5a5a727bb6bf8f828eedbab527da91082a214ea4f64a3b8750a6"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-manual"},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-DATETIME-TABLE","file":"functions-datetime.html","sha256":"8c5053713aeaacfbe4cb00effc61f10d457c98b2a29c724b10b93819a087ea95","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"date-bin","SourceDatabase":"center","Version":"18","Locale":"en","Title":"date_bin","Summary":"Bin input into specified interval aligned with specified origin; see Section 9.9.3","BodyHTML":"Bin input into specified interval aligned with specified origin; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" rel=\"nofollow\"\u003eSection 9.9.3\u003c/a\u003e","SourceRevision":"wiki-repair-20261023:eb2fc95fdc5365ead48ba5b3c28cfc1f3be26f8313172639c558d9f13749192f","ContentHash":"8920cf365f29ca5e29f714a167f1ea2815509fcd0a5cc82cbb6024efb969bcfb","Payload":{"description":"Bin input into specified interval aligned with specified origin; see Section 9.9.3","description_html":"Bin input into specified interval aligned with specified origin; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003eSection 9.9.3\u003c/a\u003e","signatures":[{"description":"Bin input into specified interval aligned with specified origin; see Section 9.9.3","description_html":"Bin input into specified interval aligned with specified origin; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003eSection 9.9.3\u003c/a\u003e","description_zh":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见第 9.9.3 节","description_zh_html":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003e第 9.9.3 节\u003c/a\u003e","examples":[{"expr":"date_bin('15 minutes', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00')","result":"2001-02-16 20:35:00"}],"html":"\u003ccode class=\"function\"\u003edate_bin\u003c/code\u003e ( \u003ccode class=\"type\"\u003einterval\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etimestamp\u003c/code\u003e","returns":"timestamp","text":"date_bin ( interval, timestamp, timestamp ) → timestamp","zh_from":"same-version-manual"},{"description":"source is a value expression of type timestamp or timestamp with time zone. (Values of type date are cast automatically to timestamp.) stride is a value expression of type interval. The return value is likewise of type timestamp or timestamp with time zone, and it marks the beginning of the bin into which the source is placed.","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 or \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e. (Values of type \u003ccode class=\"type\"\u003edate\u003c/code\u003e are cast automatically to \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e.) \u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e is a value expression of type \u003ccode class=\"type\"\u003einterval\u003c/code\u003e. The return value is likewise of type \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e or \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, and it marks the beginning of the bin into which the \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e is placed.","description_zh":"source 是 timestamp 或 timestamp with time zone 类型的值表达式。（类型 date 的值会自动转换为 timestamp。）stride 是 interval 类型的值表达式。返回值同样是 timestamp 或 timestamp with time zone 类型，并且它表示 source 所在分箱的起点。","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\"\u003edate\u003c/code\u003e 的值会自动转换为 \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e。）\u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e 是 \u003ccode class=\"type\"\u003einterval\u003c/code\u003e 类型的值表达式。返回值同样是 \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e 或 \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e 类型，并且它表示 \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e 所在分箱的起点。","examples":[],"html":"\u003ccode class=\"function\"\u003edate_bin\u003c/code\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eorigin\u003c/code\u003e\u003c/em\u003e)","returns":"","text":"date_bin(stride, source, origin)","zh_from":"same-version-manual"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"81fb837f54124671227d96e30b0e316416c4a5d47e804f4e2471c42c5a3ffff1","Text":"date_bin ( interval, timestamp, timestamp ) → timestamp","Returns":"timestamp","Payload":{"description":"Bin input into specified interval aligned with specified origin; see Section 9.9.3","description_html":"Bin input into specified interval aligned with specified origin; see \u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003eSection 9.9.3\u003c/a\u003e","description_zh":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见第 9.9.3 节","description_zh_html":"将输入按指定的间隔进行分箱（bin），对齐到指定的原点；参见\u003ca href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-BIN\" title=\"9.9.3. date_bin\"\u003e第 9.9.3 节\u003c/a\u003e","examples":[{"expr":"date_bin('15 minutes', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00')","result":"2001-02-16 20:35:00"}],"html":"\u003ccode class=\"function\"\u003edate_bin\u003c/code\u003e ( \u003ccode class=\"type\"\u003einterval\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e, \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etimestamp\u003c/code\u003e","returns":"timestamp","text":"date_bin ( interval, timestamp, timestamp ) → timestamp","zh_from":"same-version-manual"}},{"Version":"18","Ordinal":1,"Hash":"6f7c9548b9b8ce4bd1dfe27391d4bc838a6c86b9333a3f2f9efc843d03b28f5f","Text":"date_bin(stride, source, origin)","Returns":"","Payload":{"description":"source is a value expression of type timestamp or timestamp with time zone. (Values of type date are cast automatically to timestamp.) stride is a value expression of type interval. The return value is likewise of type timestamp or timestamp with time zone, and it marks the beginning of the bin into which the source is placed.","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 or \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e. (Values of type \u003ccode class=\"type\"\u003edate\u003c/code\u003e are cast automatically to \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e.) \u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e is a value expression of type \u003ccode class=\"type\"\u003einterval\u003c/code\u003e. The return value is likewise of type \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e or \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e, and it marks the beginning of the bin into which the \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e is placed.","description_zh":"source 是 timestamp 或 timestamp with time zone 类型的值表达式。（类型 date 的值会自动转换为 timestamp。）stride 是 interval 类型的值表达式。返回值同样是 timestamp 或 timestamp with time zone 类型，并且它表示 source 所在分箱的起点。","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\"\u003edate\u003c/code\u003e 的值会自动转换为 \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e。）\u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e 是 \u003ccode class=\"type\"\u003einterval\u003c/code\u003e 类型的值表达式。返回值同样是 \u003ccode class=\"type\"\u003etimestamp\u003c/code\u003e 或 \u003ccode class=\"type\"\u003etimestamp with time zone\u003c/code\u003e 类型，并且它表示 \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e 所在分箱的起点。","examples":[],"html":"\u003ccode class=\"function\"\u003edate_bin\u003c/code\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003estride\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eorigin\u003c/code\u003e\u003c/em\u003e)","returns":"","text":"date_bin(stride, source, origin)","zh_from":"same-version-manual"}}],"Spellings":null,"SQLState":null,"Evidence":null}
