{"kind": "type", "slug": "timestamp", "name": "timestamp without time zone", "major": "18", "snapshot": {"casts": [{"castfunc": "timestamp(date)", "castmethod": "f", "castsource": "date", "casttarget": "timestamp", "castcontext": "i"}, {"castfunc": "date(timestamp)", "castmethod": "f", "castsource": "timestamp", "casttarget": "date", "castcontext": "a"}, {"castfunc": "time(timestamp)", "castmethod": "f", "castsource": "timestamp", "casttarget": "time", "castcontext": "a"}, {"castfunc": "timestamptz(timestamp)", "castmethod": "f", "castsource": "timestamp", "casttarget": "timestamptz", "castcontext": "i"}, {"castfunc": "timestamp(timestamptz)", "castmethod": "f", "castsource": "timestamptz", "casttarget": "timestamp", "castcontext": "a"}, {"castfunc": "timestamp(timestamp,int4)", "castmethod": "f", "castsource": "timestamp", "casttarget": "timestamp", "castcontext": "i"}], "facts": [{"label": "目录名称", "value": "pg_catalog.timestamp"}, {"label": "类型 OID", "value": "1114"}, {"label": "类型种类", "value": "基础类型"}, {"label": "声明长度", "value": "8 字节"}, {"label": "存储策略", "value": "plain"}, {"label": "输入函数", "value": "timestamp_in"}, {"label": "输出函数", "value": "timestamp_out"}, {"label": "手册中的声明", "value": "timestamp [ ( p ) ] [ without time zone ]"}, {"label": "存储大小", "value": "8 字节"}, {"label": "手册说明", "value": "包括日期和时间（无时区）"}, {"label": "下限", "value": "公元前 4713 年"}, {"label": "上限", "value": "公元 294276 年"}, {"label": "精度", "value": "1 微秒"}], "ranges": [], "aliases": ["timestamp"], "catalog": {"oid": "1114", "descr": "date and time", "typacl": "_null_", "typlen": "8", "typelem": "0", "typname": "timestamp", "typsend": "timestamp_send", "typtype": "b", "typalign": "d", "typarray": "0", "typbyval": "FLOAT8PASSBYVAL", "typdelim": "','", "typinput": "timestamp_in", "typmodin": "timestamptypmodin", "typndims": "0", "typowner": "POSTGRES", "typrelid": "0", "typmodout": "timestamptypmodout", "typoutput": "timestamp_out", "typtypmod": "-1", "typanalyze": "-", "typdefault": "_null_", "typnotnull": "f", "typreceive": "timestamp_recv", "typstorage": "p", "typbasetype": "0", "typcategory": "D", "typcollation": "0", "typisdefined": "t", "typnamespace": "pg_catalog", "typsubscript": "-", "typdefaultbin": "_null_", "array_type_oid": "1115", "typispreferred": "f", "array_type_name": "_timestamp"}, "related": [{"url": "/wiki/catalog/pg_type/?v=18", "label": "pg_type 系统目录"}, {"url": "/wiki/catalog/pg_cast/?v=18", "label": "pg_cast 系统目录"}, {"url": "/wiki/catalog/pg_operator/?v=18", "label": "pg_operator 系统目录"}, {"url": "/wiki/catalog/pg_opclass/?v=18", "label": "pg_opclass 系统目录"}, {"url": "/wiki/type/arrays/?v=18", "label": "数组"}, {"url": "/wiki/indexam/brin/?v=18", "label": "brin 索引访问方法"}, {"url": "/wiki/indexam/btree/?v=18", "label": "btree 索引访问方法"}, {"url": "/wiki/indexam/hash/?v=18", "label": "hash 索引访问方法"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "revision": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f", "source_files": {"doc/src/sgml/datatype.sgml": "86328daa77e20d81d222376ec0306d9841a17104e436c08d138eb763aefb3700", "src/include/catalog/pg_am.h": "3426799df799f32163fcc0765f43dbdb5e88e626acf31284fef9fc6014b69d8e", "src/include/catalog/pg_am.dat": "b3cb86b102a42fb0024cbd99779c9897afb40d12a71f5cc5a0e5aee7ff2f9969", "src/include/catalog/pg_cast.h": "de585c7df687d698e7d1d100dce8a794ac9da52414ea48169191019178c8f053", "src/include/catalog/pg_proc.h": "f7d59f07c5b95e2f3c7141762a0f576e8a3af7581ba54c27537f4d500472bea5", "src/include/catalog/pg_type.h": "8fb198749fd82b6c1818a3c18455f226f66116fcfeb3d4959c65ce3fda22802e", "src/include/catalog/pg_range.h": "45546d952b5181f989bd9234721897fc2b37005c8e49ce2ddc156f26974c3ca4", "src/include/catalog/pg_cast.dat": "97911281ca2c81917394ccb2ec13367e37c6801fd461d5e1a3d2f28b911b46b2", "src/include/catalog/pg_proc.dat": "1f934ce80d460159dda137714374a35f9896315ea2476709cbb4da13b38ef95a", "src/include/catalog/pg_type.dat": "5f5887b75677cba2d4a1a0cfeb355df5ed91f85d385fac88bd8d7c605b3578f9", "src/include/catalog/pg_opclass.h": "9c218537806c8ef0398302faaca7f91315dfc1198c48706cebffb479b68defaf", "src/include/catalog/pg_range.dat": "5c2271f8e89e9378d1887204e5785060b77405b5f0ff3e6c719250c9c1dcfcc4", "src/include/catalog/pg_operator.h": "621b18cfffe102413d79b746ce7a10f77fc60fdd097bac34c22b31070d3ee3c4", "src/include/catalog/pg_opfamily.h": "e1f5fc8aebd3042df847455bf66bf755f768c2aa8a9b03d22f7ec8563eba59c0", "src/include/catalog/pg_opclass.dat": "4ee7d3619a6aa106e1c0db55de903931c7d11b1c60ba053a022519c55f8ee668", "src/include/catalog/pg_operator.dat": "5d35b9b2ef5f9797cc815263927ef8a12367fedace53e828b4e8b320e2a7f703", "src/include/catalog/pg_opfamily.dat": "3b694879027b858f2ecf1fa1152b7e30c6e15a216ba99c2384291c30e9d52311"}, "manual_sha256": {"arrays.html": "0e1d5c5a7b4a949d4439995f44f74ad4264e050d16eb9ad2a850fbaee04032df", "domains.html": "82d486973ccc35d14276627a67ac76b434452f23f9ed4d8aa3fbb01fdf285fc2", "datatype.html": "e581f67c74e42006289638c8659e9b338adbfd7f068bd8bf2b3be3880fcd2254", "rowtypes.html": "74f99e029c3a9edfd3e18810ba3c8cb66d3aada91eb67b86476560871e6617e9", "rangetypes.html": "e4960abc7ce8e51d794f94f1e57b099d30b7f75dd7f2b23a960eef91f6291c33", "datatype-bit.html": "c49124aad561636c18080b9e09572fde7785a6b9eae86f5a33283f0fd6774c37", "datatype-oid.html": "8b3360302225f08ae72716ce1804596de95b568e5d31f788cb4597427b28cc38", "datatype-xml.html": "061fc2295b7b69be704f0a741b8decd10ad721059f871fb0243c669bb54d7822", "datatype-enum.html": "cab38e53222e30cc94b24de4b33634fd22d7c93f58ebcf35f646c9b8da78fae8", "datatype-json.html": "650162a05b660146b500a205d523374d00aee117a6a6240d30262be51b6e33e5", "datatype-uuid.html": "292b307b3223c6182bdba687e7f69e6dca9038430143ad79d56327f6ed4c3246", "datatype-money.html": "8b29c14b90679683ac5c472b59a0a7e2853f32cc7db43fab417b2697a6879964", "functions-info.html": "78ac80bf81da2e4f4a33f3b850faa86f0f58ec54a083d6c31da557907de0df87", "catalog-pg-type.html": "ea9c9313bab8e92a7da18ebc50c7ff1f908dd80999a7e0ca3bbc82ba626c58d4", "datatype-binary.html": "0c03ec47b76e37888a3da7f5dcfd340128a5d356642a85185cc9ebe17856a904", "datatype-pg-lsn.html": "339172f5107cc7eb7139bec911277647219e92a532cebd0f3da0a5dacf8195af", "datatype-pseudo.html": "c7cf0b8214304bd8702c95f2142671ae5f0d631f83717f9c07d9e1f2579961b4", "datatype-boolean.html": "b633f663e6c8276e7056287640c413aa79dbc15d5353cee0d41653d58d376956", "datatype-numeric.html": "b74619f7ac2f1ca9f85c48073df78c33dd30e464e61baba6008634534edcb500", "sql-createdomain.html": "e94f927196de1b0ea1ce35cd4603c1f6f544439adcc0edf1c4222358e832245b", "datatype-datetime.html": "e366275d8b13845bfa4ef0d68faa093e5f3ecb708a1ec870cbcbf7e425b85699", "datatype-character.html": "c73eebe413ea709a7792e4cfc3cfe9fb68cb496ebe83c3ebaa9d09f8c40d0f73", "datatype-geometric.html": "0eb3053cfe7d6b0a4b5592c5d7af8d97cae527e87f063c5793413bcba5c14cd9", "datatype-net-types.html": "96846e641cc37727ddcd8b8a1aa0dbe33cd9787760a2b4efb0dcb9403d5be63f", "datatype-textsearch.html": "4b15e05be8b49a71b28aea22f2c46d0dbf639a91e7b4fe129a4c737c6daad47c"}, "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "https://pg.center/docs/18/datatype-datetime.html", "path": "datatype-datetime.html", "label": "PostgreSQL 18 English manual", "sha256": "e366275d8b13845bfa4ef0d68faa093e5f3ecb708a1ec870cbcbf7e425b85699", "language": "en", "original_url": "/docs/18/datatype-datetime.html"}, {"url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}], "coverage": "source inventory; exact declared input types for operator classes", "sections": [], "operators": [{"oid": "2060", "descr": "equal", "oprcom": "=(timestamp,timestamp)", "oprcode": "timestamp_eq", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "=", "oprrest": "eqsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<>(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "t", "oprcanmerge": "t", "oprnamespace": "pg_catalog"}, {"oid": "2061", "descr": "not equal", "oprcom": "<>(timestamp,timestamp)", "oprcode": "timestamp_ne", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<>", "oprrest": "neqsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "=(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2062", "descr": "less than", "oprcom": ">(timestamp,timestamp)", "oprcode": "timestamp_lt", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<", "oprrest": "scalarltsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": ">=(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2063", "descr": "less than or equal", "oprcom": ">=(timestamp,timestamp)", "oprcode": "timestamp_le", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<=", "oprrest": "scalarlesel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": ">(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2064", "descr": "greater than", "oprcom": "<(timestamp,timestamp)", "oprcode": "timestamp_gt", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">", "oprrest": "scalargtsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<=(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2065", "descr": "greater than or equal", "oprcom": "<=(timestamp,timestamp)", "oprcode": "timestamp_ge", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">=", "oprrest": "scalargesel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2066", "descr": "add", "oprcom": "+(interval,timestamp)", "oprcode": "timestamp_pl_interval", "oprjoin": "-", "oprkind": "b", "oprleft": "timestamp", "oprname": "+", "oprrest": "-", "oprowner": "POSTGRES", "oprright": "interval", "oprnegate": "0", "oprresult": "timestamp", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2067", "descr": "subtract", "oprcom": "0", "oprcode": "timestamp_mi", "oprjoin": "-", "oprkind": "b", "oprleft": "timestamp", "oprname": "-", "oprrest": "-", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "0", "oprresult": "interval", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2068", "descr": "subtract", "oprcom": "0", "oprcode": "timestamp_mi_interval", "oprjoin": "-", "oprkind": "b", "oprleft": "timestamp", "oprname": "-", "oprrest": "-", "oprowner": "POSTGRES", "oprright": "interval", "oprnegate": "0", "oprresult": "timestamp", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2345", "descr": "less than", "oprcom": ">(timestamp,date)", "oprcode": "date_lt_timestamp", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "date", "oprname": "<", "oprrest": "scalarltsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": ">=(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2346", "descr": "less than or equal", "oprcom": ">=(timestamp,date)", "oprcode": "date_le_timestamp", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "date", "oprname": "<=", "oprrest": "scalarlesel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": ">(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2347", "descr": "equal", "oprcom": "=(timestamp,date)", "oprcode": "date_eq_timestamp", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "date", "oprname": "=", "oprrest": "eqsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<>(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t", "oprnamespace": "pg_catalog"}, {"oid": "2348", "descr": "greater than or equal", "oprcom": "<=(timestamp,date)", "oprcode": "date_ge_timestamp", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "date", "oprname": ">=", "oprrest": "scalargesel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2349", "descr": "greater than", "oprcom": "<(timestamp,date)", "oprcode": "date_gt_timestamp", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "date", "oprname": ">", "oprrest": "scalargtsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<=(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2350", "descr": "not equal", "oprcom": "<>(timestamp,date)", "oprcode": "date_ne_timestamp", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "date", "oprname": "<>", "oprrest": "neqsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "=(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2371", "descr": "less than", "oprcom": ">(date,timestamp)", "oprcode": "timestamp_lt_date", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<", "oprrest": "scalarltsel", "oprowner": "POSTGRES", "oprright": "date", "oprnegate": ">=(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2372", "descr": "less than or equal", "oprcom": ">=(date,timestamp)", "oprcode": "timestamp_le_date", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<=", "oprrest": "scalarlesel", "oprowner": "POSTGRES", "oprright": "date", "oprnegate": ">(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2373", "descr": "equal", "oprcom": "=(date,timestamp)", "oprcode": "timestamp_eq_date", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "=", "oprrest": "eqsel", "oprowner": "POSTGRES", "oprright": "date", "oprnegate": "<>(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t", "oprnamespace": "pg_catalog"}, {"oid": "2374", "descr": "greater than or equal", "oprcom": "<=(date,timestamp)", "oprcode": "timestamp_ge_date", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">=", "oprrest": "scalargesel", "oprowner": "POSTGRES", "oprright": "date", "oprnegate": "<(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2375", "descr": "greater than", "oprcom": "<(date,timestamp)", "oprcode": "timestamp_gt_date", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">", "oprrest": "scalargtsel", "oprowner": "POSTGRES", "oprright": "date", "oprnegate": "<=(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2376", "descr": "not equal", "oprcom": "<>(date,timestamp)", "oprcode": "timestamp_ne_date", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<>", "oprrest": "neqsel", "oprowner": "POSTGRES", "oprright": "date", "oprnegate": "=(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2534", "descr": "less than", "oprcom": ">(timestamptz,timestamp)", "oprcode": "timestamp_lt_timestamptz", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<", "oprrest": "scalarltsel", "oprowner": "POSTGRES", "oprright": "timestamptz", "oprnegate": ">=(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2535", "descr": "less than or equal", "oprcom": ">=(timestamptz,timestamp)", "oprcode": "timestamp_le_timestamptz", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<=", "oprrest": "scalarlesel", "oprowner": "POSTGRES", "oprright": "timestamptz", "oprnegate": ">(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2536", "descr": "equal", "oprcom": "=(timestamptz,timestamp)", "oprcode": "timestamp_eq_timestamptz", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "=", "oprrest": "eqsel", "oprowner": "POSTGRES", "oprright": "timestamptz", "oprnegate": "<>(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t", "oprnamespace": "pg_catalog"}, {"oid": "2537", "descr": "greater than or equal", "oprcom": "<=(timestamptz,timestamp)", "oprcode": "timestamp_ge_timestamptz", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">=", "oprrest": "scalargesel", "oprowner": "POSTGRES", "oprright": "timestamptz", "oprnegate": "<(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2538", "descr": "greater than", "oprcom": "<(timestamptz,timestamp)", "oprcode": "timestamp_gt_timestamptz", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">", "oprrest": "scalargtsel", "oprowner": "POSTGRES", "oprright": "timestamptz", "oprnegate": "<=(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2539", "descr": "not equal", "oprcom": "<>(timestamptz,timestamp)", "oprcode": "timestamp_ne_timestamptz", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<>", "oprrest": "neqsel", "oprowner": "POSTGRES", "oprright": "timestamptz", "oprnegate": "=(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2540", "descr": "less than", "oprcom": ">(timestamp,timestamptz)", "oprcode": "timestamptz_lt_timestamp", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "<", "oprrest": "scalarltsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": ">=(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2541", "descr": "less than or equal", "oprcom": ">=(timestamp,timestamptz)", "oprcode": "timestamptz_le_timestamp", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "<=", "oprrest": "scalarlesel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": ">(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2542", "descr": "equal", "oprcom": "=(timestamp,timestamptz)", "oprcode": "timestamptz_eq_timestamp", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "=", "oprrest": "eqsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<>(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t", "oprnamespace": "pg_catalog"}, {"oid": "2543", "descr": "greater than or equal", "oprcom": "<=(timestamp,timestamptz)", "oprcode": "timestamptz_ge_timestamp", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": ">=", "oprrest": "scalargesel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2544", "descr": "greater than", "oprcom": "<(timestamp,timestamptz)", "oprcode": "timestamptz_gt_timestamp", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": ">", "oprrest": "scalargtsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "<=(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2545", "descr": "not equal", "oprcom": "<>(timestamp,timestamptz)", "oprcode": "timestamptz_ne_timestamp", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "<>", "oprrest": "neqsel", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "=(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}, {"oid": "2553", "descr": "add", "oprcom": "+(timestamp,interval)", "oprcode": "interval_pl_timestamp", "oprjoin": "-", "oprkind": "b", "oprleft": "interval", "oprname": "+", "oprrest": "-", "oprowner": "POSTGRES", "oprright": "timestamp", "oprnegate": "0", "oprresult": "timestamp", "oprcanhash": "f", "oprcanmerge": "f", "oprnamespace": "pg_catalog"}], "signature": "timestamp [ ( p ) ] [ without time zone ]", "description": ["日期和时间（不含时区）"], "manual_html": "<div class=\"sect1\" id=\"DATATYPE-DATETIME\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\" lang=\"zh\">\n<div>\n<div>\n<h2 class=\"title\" style=\"clear: both\">8.5. 日期/时间类型 </h2>\n</div>\n</div>\n</h2>\n</div>\n</div>\n</div>\n<p lang=\"zh\"><span class=\"productname\">PostgreSQL</span> 支持完整的一组 <acronym class=\"acronym\">SQL</acronym> 日期和时间类型，如<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-TABLE\" title=\"表 8.9. 日期/时间类型\">表 8.9</a>所示。这些数据类型上可用的操作见<a class=\"xref\" href=\"/docs/18/functions-datetime.html\" title=\"9.9. 日期/时间函数和操作符\">第 9.9 节</a>。日期按格里高利历计算，即使是在该历法启用之前的年份也是如此（更多信息见<a class=\"xref\" href=\"/docs/18/datetime-units-history.html\" title=\"B.6. 历法的历史\">第 B.6 节</a>）。</p>\n<div class=\"table\" id=\"DATATYPE-DATETIME-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.9. 日期/时间类型</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">名字</th>\n<th lang=\"zh\">存储大小</th>\n<th lang=\"zh\">说明</th>\n<th lang=\"zh\">下限</th>\n<th lang=\"zh\">上限</th>\n<th lang=\"zh\">精度</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"type\">timestamp [ (<em class=\"replaceable\"><code>p</code></em>) ] [ without time zone ]</code></td>\n<td lang=\"zh\">8 字节</td>\n<td lang=\"zh\">包括日期和时间（无时区）</td>\n<td lang=\"zh\">公元前 4713 年</td>\n<td lang=\"zh\">公元 294276 年</td>\n<td lang=\"zh\">1 微秒</td>\n</tr>\n<tr>\n<td><code class=\"type\">timestamp [ (<em class=\"replaceable\"><code>p</code></em>) ] with time zone</code></td>\n<td lang=\"zh\">8 字节</td>\n<td lang=\"zh\">包括日期和时间，有时区</td>\n<td lang=\"zh\">公元前 4713 年</td>\n<td lang=\"zh\">公元 294276 年</td>\n<td lang=\"zh\">1 微秒</td>\n</tr>\n<tr>\n<td><code class=\"type\">date</code></td>\n<td lang=\"zh\">4 字节</td>\n<td lang=\"zh\">日期（没有一天中的时间）</td>\n<td lang=\"zh\">公元前 4713 年</td>\n<td lang=\"zh\">公元 5874897 年</td>\n<td lang=\"zh\">1 天</td>\n</tr>\n<tr>\n<td><code class=\"type\">time [ (<em class=\"replaceable\"><code>p</code></em>) ] [ without time zone ]</code></td>\n<td lang=\"zh\">8 字节</td>\n<td lang=\"zh\">一天中的时间（无日期）</td>\n<td>00:00:00</td>\n<td>24:00:00</td>\n<td lang=\"zh\">1 微秒</td>\n</tr>\n<tr>\n<td><code class=\"type\">time [ (<em class=\"replaceable\"><code>p</code></em>) ] with time zone</code></td>\n<td lang=\"zh\">12 字节</td>\n<td lang=\"zh\">一天中的时间（无日期），带时区</td>\n<td>00:00:00+1559</td>\n<td>24:00:00-1559</td>\n<td lang=\"zh\">1 微秒</td>\n</tr>\n<tr>\n<td><code class=\"type\">interval [ <em class=\"replaceable\"><code>fields</code></em> ] [ (<em class=\"replaceable\"><code>p</code></em>) ]</code></td>\n<td lang=\"zh\">16 字节</td>\n<td lang=\"zh\">时间间隔</td>\n<td lang=\"zh\">-178000000 年</td>\n<td lang=\"zh\">178000000 年</td>\n<td lang=\"zh\">1 微秒</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n<div class=\"note\">\n<h3 class=\"title\" lang=\"zh\">注意</h3>\n<p lang=\"zh\">SQL 标准要求仅写 <code class=\"type\">timestamp</code> 时，应等效于 <code class=\"type\">timestamp without time zone</code>，而 <span class=\"productname\">PostgreSQL</span> 也遵循这种行为。<code class=\"type\">timestamptz</code> 被接受为 <code class=\"type\">timestamp with time zone</code> 的简写，这是 <span class=\"productname\">PostgreSQL</span> 的扩展。</p>\n</div>\n<p><code class=\"type\">time</code>, <code class=\"type\">timestamp</code>, and <code class=\"type\">interval</code> accept an optional precision value <em class=\"replaceable\"><code>p</code></em> which specifies the number of fractional digits retained in the seconds field. By default, there is no explicit bound on precision. The allowed range of <em class=\"replaceable\"><code>p</code></em> is from 0 to 6.</p>\n<p lang=\"zh\"><code class=\"type\">interval</code> 类型还有一个附加选项，可以通过写出下面这些短语之一来限制所存储字段的集合：</p>\n<pre class=\"literallayout\">YEAR\nMONTH\nDAY\nHOUR\nMINUTE\nSECOND\nYEAR TO MONTH\nDAY TO HOUR\nDAY TO MINUTE\nDAY TO SECOND\nHOUR TO MINUTE\nHOUR TO SECOND\nMINUTE TO SECOND\n</pre>\n<p lang=\"zh\">注意，如果同时指定了 <em class=\"replaceable\"><code>fields</code></em> 和 <em class=\"replaceable\"><code>p</code></em>，那么 <em class=\"replaceable\"><code>fields</code></em> 必须包含 <code class=\"literal\">SECOND</code>，因为精度只作用于秒。</p>\n<p lang=\"zh\"><code class=\"type\">time with time zone</code> 类型由 SQL 标准定义，但其定义具有一些会让人怀疑其实用性的特性。在大多数情况下，<code class=\"type\">date</code>、<code class=\"type\">time</code>、<code class=\"type\">timestamp without time zone</code> 和 <code class=\"type\">timestamp with time zone</code> 的组合，就足以提供任何应用所需的完整日期/时间功能。</p>\n<div class=\"sect2\" id=\"DATATYPE-DATETIME-INPUT\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h3 class=\"title\" lang=\"zh\"><span class=\"sect2\"><a href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-INPUT\">8.5.1. 日期/时间输入</a></span></h3>\n</div>\n</div>\n</div>\n<p lang=\"zh\">日期和时间输入几乎可以使用任何合理格式，包括 ISO 8601、SQL 兼容格式、传统 POSTGRES 格式及其他格式。某些格式中的日、月、年排列顺序存在歧义，因此支持指定这些字段的预期顺序。将 DateStyle 参数设为 MDY 可按月-日-年解释，设为 DMY 可按日-月-年解释，设为 YMD 可按年-月-日解释。</p>\n<p lang=\"zh\"><span class=\"productname\">PostgreSQL</span> 在处理日期/时间输入方面，比 <acronym class=\"acronym\">SQL</acronym> 标准要求的更灵活。有关日期/时间输入的精确解析规则，以及可识别的文本字段（包括月份、星期几和时区），请参见<a class=\"xref\" href=\"/docs/18/datetime-appendix.html\" title=\"附录 B. 日期/时间支持\">附录 B</a>。</p>\n<p lang=\"zh\">请记住，任何日期或时间字面值输入都必须像文本字符串一样用单引号括起来。更多信息请参见<a class=\"xref\" href=\"/docs/18/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-GENERIC\" title=\"4.1.2.7. 其他类型的常量\">第 4.1.2.7 节</a>。<acronym class=\"acronym\">SQL</acronym> 要求使用下列语法：</p>\n<pre class=\"synopsis\"><em class=\"replaceable\"><code>type</code></em> [ (<em class=\"replaceable\"><code>p</code></em>) ] '<em class=\"replaceable\"><code>value</code></em>'\n</pre>\n<p lang=\"zh\">其中，p 是可选的精度说明，给出秒字段的小数位数。time、timestamp 和 interval 类型可以指定精度，范围为 0 至 6。如果常量写法中未指定精度，则默认采用字面值的精度（但不超过 6 位）。</p>\n<div class=\"sect3\" id=\"DATATYPE-DATETIME-INPUT-DATES\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h4 class=\"title\" lang=\"zh\">\n<div>\n<div>\n<h4 class=\"title\">8.5.1.1. 日期 </h4>\n</div>\n</div>\n</h4>\n</div>\n</div>\n</div>\n<p lang=\"zh\"><a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-DATE-TABLE\" title=\"表 8.10. 日期输入\">表 8.10</a>显示了<code class=\"type\">date</code>类型可能的输入方式。</p>\n<div class=\"table\" id=\"DATATYPE-DATETIME-DATE-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.10. 日期输入</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">示例</th>\n<th lang=\"zh\">说明</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>1999-01-08</td>\n<td lang=\"zh\">ISO 8601；在任何模式下均为 1 月 8 日（推荐格式）</td>\n</tr>\n<tr>\n<td lang=\"zh\">1999 年 1 月 8 日</td>\n<td lang=\"zh\">在任何<code class=\"varname\">datestyle</code>输入模式下都无歧义</td>\n</tr>\n<tr>\n<td>1/8/1999</td>\n<td lang=\"zh\">在 MDY 模式下为 1 月 8 日；在 DMY 模式下为 8 月 1 日</td>\n</tr>\n<tr>\n<td>1/18/1999</td>\n<td lang=\"zh\">在 MDY 模式下为 1 月 18 日；其他模式下不接受</td>\n</tr>\n<tr>\n<td>01/02/03</td>\n<td lang=\"zh\">在 MDY 模式下为 2003 年 1 月 2 日；在 DMY 模式下为 2003 年 2 月 1 日；在 YMD 模式下为 2001 年 2 月 3 日</td>\n</tr>\n<tr>\n<td>1999-Jan-08</td>\n<td lang=\"zh\">在任何模式下均为 1 月 8 日</td>\n</tr>\n<tr>\n<td>Jan-08-1999</td>\n<td lang=\"zh\">在任何模式下均为 1 月 8 日</td>\n</tr>\n<tr>\n<td>08-Jan-1999</td>\n<td lang=\"zh\">在任何模式下均为 1 月 8 日</td>\n</tr>\n<tr>\n<td>99-Jan-08</td>\n<td lang=\"zh\">在 YMD 模式下为 1 月 8 日，否则报错</td>\n</tr>\n<tr>\n<td>08-Jan-99</td>\n<td lang=\"zh\">1 月 8 日，但在 YMD 模式下报错</td>\n</tr>\n<tr>\n<td>Jan-08-99</td>\n<td lang=\"zh\">1 月 8 日，但在 YMD 模式下报错</td>\n</tr>\n<tr>\n<td>19990108</td>\n<td lang=\"zh\">ISO 8601；在任何模式下均为 1999 年 1 月 8 日</td>\n</tr>\n<tr>\n<td>990108</td>\n<td lang=\"zh\">ISO 8601；在任何模式下均为 1999 年 1 月 8 日</td>\n</tr>\n<tr>\n<td>1999.008</td>\n<td lang=\"zh\">年和一年中的第几天</td>\n</tr>\n<tr>\n<td>J2451187</td>\n<td lang=\"zh\">儒略日</td>\n</tr>\n<tr>\n<td lang=\"zh\">公元前 99 年 1 月 8 日</td>\n<td lang=\"zh\">公元前 99 年</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n</div>\n<div class=\"sect3\" id=\"DATATYPE-DATETIME-INPUT-TIMES\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h4 class=\"title\" lang=\"zh\">\n<div>\n<div>\n<h4 class=\"title\">8.5.1.2. 时间 </h4>\n</div>\n</div>\n</h4>\n</div>\n</div>\n</div>\n<p lang=\"zh\">一天中的时间类型包括 <code class=\"type\">time [ (<em class=\"replaceable\"><code>p</code></em>) ] without time zone</code> 和 <code class=\"type\">time [ (<em class=\"replaceable\"><code>p</code></em>) ] with time zone</code>。单独写 <code class=\"type\">time</code> 等效于 <code class=\"type\">time without time zone</code>。</p>\n<p lang=\"zh\">这些类型的有效输入由一个一天中的时间，加上一个可选时区组成（见<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-TIME-TABLE\" title=\"表 8.11. 时间输入\">表 8.11</a>和<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-TIMEZONE-TABLE\" title=\"表 8.12. 时区输入\">表 8.12</a>）。如果在 <code class=\"type\">time without time zone</code> 的输入中指定了时区，它会被静默忽略。你也可以指定一个日期，但它同样会被忽略，除非你使用了涉及夏令时规则的时区名称，例如 <code class=\"literal\">America/New_York</code>。在这种情况下，必须指定日期，以便确定应适用标准时间还是夏令时。相应的时区偏移会被记录到 <code class=\"type\">time with time zone</code> 值中，并按存储时的样子输出；它不会根据当前活动时区进行调整。</p>\n<div class=\"table\" id=\"DATATYPE-DATETIME-TIME-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.11. 时间输入</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">示例</th>\n<th lang=\"zh\">说明</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"literal\">04:05:06.789</code></td>\n<td>ISO 8601</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05:06</code></td>\n<td>ISO 8601</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05</code></td>\n<td>ISO 8601</td>\n</tr>\n<tr>\n<td><code class=\"literal\">040506</code></td>\n<td>ISO 8601</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05 AM</code></td>\n<td lang=\"zh\">与 04:05 相同；AM 不影响值</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05 PM</code></td>\n<td lang=\"zh\">与 16:05 相同；输入的小时必须 &lt;= 12</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05:06.789-8</code></td>\n<td lang=\"zh\">ISO 8601，时区以 UTC 偏移表示</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05:06-08:00</code></td>\n<td lang=\"zh\">ISO 8601，时区以 UTC 偏移表示</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05-08:00</code></td>\n<td lang=\"zh\">ISO 8601，时区以 UTC 偏移表示</td>\n</tr>\n<tr>\n<td><code class=\"literal\">040506-08</code></td>\n<td lang=\"zh\">ISO 8601，时区以 UTC 偏移表示</td>\n</tr>\n<tr>\n<td><code class=\"literal\">040506+0730</code></td>\n<td lang=\"zh\">ISO 8601，时区的 UTC 偏移不是整小时</td>\n</tr>\n<tr>\n<td><code class=\"literal\">040506+07:30:00</code></td>\n<td lang=\"zh\">精确到秒的 UTC 偏移量（ISO 8601 不允许）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">04:05:06 PST</code></td>\n<td lang=\"zh\">缩写指定的时区</td>\n</tr>\n<tr>\n<td><code class=\"literal\">2003-04-12 04:05:06 America/New_York</code></td>\n<td lang=\"zh\">全名指定的时区</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n<div class=\"table\" id=\"DATATYPE-TIMEZONE-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.12. 时区输入</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">示例</th>\n<th lang=\"zh\">说明</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"literal\">PST</code></td>\n<td lang=\"zh\">缩写（太平洋标准时间）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">America/New_York</code></td>\n<td lang=\"zh\">完整时区名</td>\n</tr>\n<tr>\n<td><code class=\"literal\">PST8PDT</code></td>\n<td lang=\"zh\">POSIX风格的时区声明</td>\n</tr>\n<tr>\n<td><code class=\"literal\">-8:00:00</code></td>\n<td lang=\"zh\">PST的UTC偏移</td>\n</tr>\n<tr>\n<td><code class=\"literal\">-8:00</code></td>\n<td lang=\"zh\">PST 的 UTC 偏移量（ISO 8601 扩展格式）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">-800</code></td>\n<td lang=\"zh\">PST 的 UTC 偏移量（ISO 8601 基本格式）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">-8</code></td>\n<td lang=\"zh\">PST 的 UTC 偏移量（ISO 8601 基本格式）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">zulu</code></td>\n<td lang=\"zh\">UTC的军方缩写</td>\n</tr>\n<tr>\n<td><code class=\"literal\">z</code></td>\n<td lang=\"zh\">zulu 的简写形式（也见于 ISO 8601）</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n<p lang=\"zh\">关于如何指定时区，参见<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-TIMEZONES\" title=\"8.5.3. 时区\">第 8.5.3 节</a>。</p>\n</div>\n<div class=\"sect3\" id=\"DATATYPE-DATETIME-INPUT-TIME-STAMPS\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h4 class=\"title\" lang=\"zh\">\n<div>\n<div>\n<h4 class=\"title\">8.5.1.3. 时间戳 </h4>\n</div>\n</div>\n</h4>\n</div>\n</div>\n</div>\n<p lang=\"zh\">时间戳类型的有效输入由一个日期和时间的串接组成，后面跟着一个可选时区，以及一个可选的 <code class=\"literal\">AD</code> 或 <code class=\"literal\">BC</code>（另外，<code class=\"literal\">AD</code>/<code class=\"literal\">BC</code> 也可以出现在时区前面，但这种顺序并不推荐）。因此：</p>\n<pre class=\"programlisting\">1999-01-08 04:05:06\n</pre>\n<p lang=\"zh\">和：</p>\n<pre class=\"programlisting\">1999-01-08 04:05:06 -8:00\n</pre>\n<p lang=\"zh\">都是遵循 <acronym class=\"acronym\">ISO</acronym> 8601 标准的有效值。另外，广泛使用的下列格式：</p>\n<pre class=\"programlisting\">January 8 04:05:06 1999 PST\n</pre>\n<p lang=\"zh\">也被支持。</p>\n<p lang=\"zh\">按照<acronym class=\"acronym\">SQL</acronym>标准，<code class=\"type\">timestamp without time zone</code>和<code class=\"type\">timestamp with time zone</code>字面量的区别在于，时间后是否有<span class=\"quote\">“<span class=\"quote\">+</span>”</span>或<span class=\"quote\">“<span class=\"quote\">-</span>”</span>符号及其后的时区偏移。因此，按照该标准，</p>\n<pre class=\"programlisting\">TIMESTAMP '2004-10-19 10:23:54'\n</pre>\n<p lang=\"zh\">是<code class=\"type\">timestamp without time zone</code>，而</p>\n<pre class=\"programlisting\">TIMESTAMP '2004-10-19 10:23:54+02'\n</pre>\n<p lang=\"zh\">是<code class=\"type\">timestamp with time zone</code>。<span class=\"productname\">PostgreSQL</span>在确定字符串字面量的类型之前，从不检查其内容，因此会把上述两者都视为<code class=\"type\">timestamp without time zone</code>。为确保字面量被视为<code class=\"type\">timestamp with time zone</code>，应为它显式指定正确类型：</p>\n<pre class=\"programlisting\">TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02'\n</pre>\n<p lang=\"zh\">对于已经确定为 <code class=\"type\">timestamp without time zone</code> 的值，<span class=\"productname\">PostgreSQL</span> 会静默忽略任何时区指示。也就是说，结果值直接取自输入字符串中的日期/时间字段，而不会因时区而调整。</p>\n<p lang=\"zh\">对于 <code class=\"type\">timestamp with time zone</code> 值，如果输入字符串中包含显式时区，则会使用该时区对应的偏移将其转换为<a class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-UTC\"></a><a class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-UTC\" title=\"UTC\">协调世界时（UTC）</a>。如果输入字符串中没有给出时区，则假定它位于系统<a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-TIMEZONE\">TimeZone</a>参数指定的时区，并使用 <code class=\"varname\">timezone</code> 时区的偏移将其转换为 UTC。无论哪种情况，该值在内部都以 UTC 存储，原先声明或假定的时区都不会被保留。</p>\n<p lang=\"zh\">当输出一个 <code class=\"type\">timestamp with time zone</code> 值时，它总会从 UTC 转换到当前 <code class=\"varname\">timezone</code> 时区，并显示为该时区的本地时间。若要查看其他时区的时间，可以修改 <code class=\"varname\">timezone</code>，或者使用 <code class=\"literal\">AT TIME ZONE</code> 构造（见<a class=\"xref\" href=\"/docs/18/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT\" title=\"9.9.4. AT TIME ZONE 和 AT LOCAL\">第 9.9.4 节</a>）。</p>\n<p lang=\"zh\">在 <code class=\"type\">timestamp without time zone</code> 和 <code class=\"type\">timestamp with time zone</code> 之间转换时，通常假定 <code class=\"type\">timestamp without time zone</code> 值应被解释为，或输出为，<code class=\"varname\">timezone</code> 本地时间。要为该转换指定不同的时区，可以使用 <code class=\"literal\">AT TIME ZONE</code>。</p>\n</div>\n<div class=\"sect3\" id=\"DATATYPE-DATETIME-SPECIAL-VALUES\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h4 class=\"title\" lang=\"zh\">\n<div>\n<div>\n<h4 class=\"title\">8.5.1.4. 特殊值 </h4>\n</div>\n</div>\n</h4>\n</div>\n</div>\n</div>\n<p lang=\"zh\">为了方便起见，<span class=\"productname\">PostgreSQL</span> 支持若干特殊的日期/时间输入值，如<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-SPECIAL-TABLE\" title=\"表 8.13. 特殊日期/时间输入\">表 8.13</a>所示。<code class=\"literal\">infinity</code> 和 <code class=\"literal\">-infinity</code> 在系统内部有特殊表示，并且输出时会保持不变；其余值则只是记法上的简写，在读取时会被转换成普通日期/时间值。（特别是，<code class=\"literal\">now</code> 及相关字符串在被读取后会立刻转换成某个特定的时间值。）这些值在 SQL 命令中作为常量使用时，都必须用单引号括起来。</p>\n<div class=\"table\" id=\"DATATYPE-DATETIME-SPECIAL-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.13. 特殊日期/时间输入</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">输入串</th>\n<th lang=\"zh\">合法类型</th>\n<th lang=\"zh\">说明</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"literal\">epoch</code></td>\n<td><code class=\"type\">date</code>, <code class=\"type\">timestamp</code></td>\n<td lang=\"zh\">1970-01-01 00:00:00+00（Unix系统时间0）</td>\n</tr>\n<tr>\n<td lang=\"zh\">无穷大</td>\n<td><code class=\"type\">date</code>, <code class=\"type\">timestamp</code>, <code class=\"type\">interval</code></td>\n<td lang=\"zh\">晚于所有其他时间戳</td>\n</tr>\n<tr>\n<td><code class=\"literal\">-infinity</code></td>\n<td><code class=\"type\">date</code>, <code class=\"type\">timestamp</code>, <code class=\"type\">interval</code></td>\n<td lang=\"zh\">早于所有其他时间戳</td>\n</tr>\n<tr>\n<td><code class=\"literal\">now</code></td>\n<td><code class=\"type\">date</code>, <code class=\"type\">time</code>, <code class=\"type\">timestamp</code></td>\n<td lang=\"zh\">当前事务的开始时间</td>\n</tr>\n<tr>\n<td><code class=\"literal\">today</code></td>\n<td><code class=\"type\">date</code>, <code class=\"type\">timestamp</code></td>\n<td lang=\"zh\">今天午夜（<code class=\"literal\">00:00</code>）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">tomorrow</code></td>\n<td><code class=\"type\">date</code>, <code class=\"type\">timestamp</code></td>\n<td lang=\"zh\">明天午夜（<code class=\"literal\">00:00</code>）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">yesterday</code></td>\n<td><code class=\"type\">date</code>, <code class=\"type\">timestamp</code></td>\n<td lang=\"zh\">昨天午夜（<code class=\"literal\">00:00</code>）</td>\n</tr>\n<tr>\n<td><code class=\"literal\">allballs</code></td>\n<td><code class=\"type\">time</code></td>\n<td>00:00:00.00 UTC</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n<p lang=\"zh\">以下兼容 SQL 的函数也可获取相应数据类型的当前时间值：CURRENT_DATE、CURRENT_TIME、CURRENT_TIMESTAMP、LOCALTIME、LOCALTIMESTAMP，见第 9.9.5 节。它们是 SQL 函数，不会在数据输入字符串中被识别。</p>\n<div class=\"caution\">\n<h3 class=\"title\" lang=\"zh\">小心</h3>\n<p lang=\"zh\">虽然输入字符串 <code class=\"literal\">now</code>、<code class=\"literal\">today</code>、<code class=\"literal\">tomorrow</code> 和 <code class=\"literal\">yesterday</code> 可用于交互式 SQL 命令，但当命令被保存以便稍后执行时，例如在预备语句、视图和函数定义中，它们的行为可能令人意外。这些字符串可能在读取时就被转换成某个具体时间值，而该值即使后来已经过时，也会继续被使用。在这类上下文中，应改用某个 SQL 函数。例如，<code class=\"literal\">CURRENT_DATE + 1</code> 比 <code class=\"literal\">'tomorrow'::date</code> 更安全。</p>\n</div>\n</div>\n</div>\n<div class=\"sect2\" id=\"DATATYPE-DATETIME-OUTPUT\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h3 class=\"title\" lang=\"zh\"><span class=\"sect2\"><a href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT\">8.5.2. 日期/时间输出</a></span></h3>\n</div>\n</div>\n</div>\n<p lang=\"zh\">日期/时间类型的输出格式可以设为四种样式之一：ISO 8601、<acronym class=\"acronym\">SQL</acronym>（Ingres）、传统的 <span class=\"productname\">POSTGRES</span>（Unix <span class=\"application\">date</span> 格式）或 German。默认是 <acronym class=\"acronym\">ISO</acronym> 格式。（<acronym class=\"acronym\">SQL</acronym> 标准要求使用 ISO 8601 格式。该输出格式之所以名为<span class=\"quote\">“<span class=\"quote\">SQL</span>”</span>，纯属历史偶然。）<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT-TABLE\" title=\"表 8.14. 日期/时间输出风格\">表 8.14</a>展示了各种输出样式的示例。<code class=\"type\">date</code> 和 <code class=\"type\">time</code> 类型的输出通常只包含示例中的日期部分或时间部分。不过，<span class=\"productname\">POSTGRES</span> 样式对纯日期值仍会采用 <acronym class=\"acronym\">ISO</acronym> 格式输出。</p>\n<div class=\"table\" id=\"DATATYPE-DATETIME-OUTPUT-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.14. 日期/时间输出风格</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">风格设置</th>\n<th lang=\"zh\">说明</th>\n<th lang=\"zh\">示例</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"literal\">ISO</code></td>\n<td lang=\"zh\">ISO 8601，SQL 标准</td>\n<td><code class=\"literal\">1997-12-17 07:37:16-08</code></td>\n</tr>\n<tr>\n<td><code class=\"literal\">SQL</code></td>\n<td lang=\"zh\">传统样式</td>\n<td><code class=\"literal\">12/17/1997 07:37:16.00 PST</code></td>\n</tr>\n<tr>\n<td><code class=\"literal\">Postgres</code></td>\n<td lang=\"zh\">原始样式</td>\n<td><code class=\"literal\">Wed Dec 17 07:37:16 1997 PST</code></td>\n</tr>\n<tr>\n<td><code class=\"literal\">German</code></td>\n<td lang=\"zh\">地区样式</td>\n<td><code class=\"literal\">17.12.1997 07:37:16.00 PST</code></td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n<div class=\"note\">\n<h3 class=\"title\" lang=\"zh\">注意</h3>\n<p>ISO 8601 specifies the use of uppercase letter <code class=\"literal\">T</code> to separate the date and time. <span class=\"productname\">PostgreSQL</span> accepts that format on input, but on output it uses a space rather than <code class=\"literal\">T</code>, as shown above. This is for readability and for consistency with <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc3339\">RFC 3339</a> as well as some other database systems.</p>\n</div>\n<p lang=\"zh\"><acronym class=\"acronym\">SQL</acronym>和POSTGRES风格中，如果指定了 DMY 字段顺序，“日”将出现在“月”之前，否则“月”出现在“日”之前（有关该设置如何影响输入值的解释，请参考<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-INPUT\" title=\"8.5.1. 日期/时间输入\">第 8.5.1 节</a>）。<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT2-TABLE\" title=\"表 8.15. 日期顺序习惯\">表 8.15</a>给出了示例。</p>\n<div class=\"table\" id=\"DATATYPE-DATETIME-OUTPUT2-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.15. 日期顺序习惯</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\"><code class=\"varname\">datestyle</code>设置</th>\n<th lang=\"zh\">输入顺序</th>\n<th lang=\"zh\">示例输出</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"literal\">SQL, DMY</code></td>\n<td lang=\"zh\">日 / 月 / 年</td>\n<td><code class=\"literal\">17/12/1997 15:37:16.00 CET</code></td>\n</tr>\n<tr>\n<td><code class=\"literal\">SQL, MDY</code></td>\n<td lang=\"zh\">月 / 日 / 年</td>\n<td><code class=\"literal\">12/17/1997 07:37:16.00 PST</code></td>\n</tr>\n<tr>\n<td><code class=\"literal\">Postgres, DMY</code></td>\n<td lang=\"zh\">日 / 月 / 年</td>\n<td><code class=\"literal\">Wed 17 Dec 07:37:16 1997 PST</code></td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n<p lang=\"zh\">在 <acronym class=\"acronym\">ISO</acronym> 样式中，时区总是显示为相对于 UTC 的有符号数字偏移，格林尼治以东的时区使用正号。如果偏移是整小时，就显示为 <em class=\"replaceable\"><code>hh</code></em>；如果是整分钟，则显示为 <em class=\"replaceable\"><code>hh</code></em>:<em class=\"replaceable\"><code>mm</code></em>；否则显示为 <em class=\"replaceable\"><code>hh</code></em>:<em class=\"replaceable\"><code>mm</code></em>:<em class=\"replaceable\"><code>ss</code></em>。（第三种情况在任何现代时区标准下都不可能出现，但在处理标准化时区被采用之前的时间戳时可能会看到。）在其他日期样式中，如果当前时区有通用的字母缩写，就会显示该缩写；否则会以 ISO 8601 基本格式的有符号数字偏移显示（<em class=\"replaceable\"><code>hh</code></em> 或 <em class=\"replaceable\"><code>hhmm</code></em>）。这些样式中显示的字母缩写，取自当前由<a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-TIMEZONE\">TimeZone</a>运行时参数选中的 IANA 时区数据库条目；它们不受<a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-TIMEZONE-ABBREVIATIONS\">timezone_abbreviations</a>设置影响。</p>\n<p lang=\"zh\">用户可以通过 <code class=\"command\">SET datestyle</code> 命令、<code class=\"filename\">postgresql.conf</code> 配置文件中的<a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-DATESTYLE\">DateStyle</a>参数，或者服务器端或客户端上的 <code class=\"envar\">PGDATESTYLE</code> 环境变量来选择日期/时间样式。</p>\n<p lang=\"zh\">格式化函数<code class=\"function\">to_char</code>（见<a class=\"xref\" href=\"/docs/18/functions-formatting.html\" title=\"9.8. 数据类型格式化函数\">第 9.8 节</a>）也可以作为一个更灵活的方式来格式化日期/时间输出。</p>\n</div>\n<div class=\"sect2\" id=\"DATATYPE-TIMEZONES\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h3 class=\"title\" lang=\"zh\"><span class=\"sect2\"><a href=\"/docs/18/datatype-datetime.html#DATATYPE-TIMEZONES\">8.5.3. 时区</a></span></h3>\n</div>\n</div>\n</div>\n<p lang=\"zh\">时区及其惯例不仅由地理位置决定，也受政治决策影响。世界各地的时区在 20 世纪逐渐得到一定程度的标准化，但仍可能随意变更，尤其是夏令时规则。PostgreSQL 使用广泛应用的 IANA（Olson）时区数据库记录历史时区规则。对于未来时间，假定某个时区最新已知的规则将一直沿用下去。</p>\n<p lang=\"zh\"><span class=\"productname\">PostgreSQL</span> 努力在典型用法上与 <acronym class=\"acronym\">SQL</acronym> 标准定义保持兼容。不过，<acronym class=\"acronym\">SQL</acronym> 标准在日期和时间类型及其能力方面存在一些奇怪的混搭。两个显而易见的问题是：</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>尽管 <code class=\"type\">date</code> 类型不能有关联的时区，<code class=\"type\">time</code> 类型却可以。但现实世界中的时区如果不同时关联日期和时间，几乎没有意义，因为偏移量可能会随着夏令时切换而在一年中发生变化。</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">默认时区以相对于 UTC 的固定数值偏移量指定，因此跨越夏令时切换边界进行日期／时间运算时，无法自动适应夏令时。</li>\n</ul>\n</div>\n<p lang=\"zh\">为了克服这些困难，我们建议在使用时区时采用同时包含日期和时间的日期/时间类型。我们<span class=\"emphasis\"><em>不</em></span>建议使用 <code class=\"type\">time with time zone</code> 类型（尽管 <span class=\"productname\">PostgreSQL</span> 出于兼容旧应用以及遵循 <acronym class=\"acronym\">SQL</acronym> 标准的考虑而支持它）。<span class=\"productname\">PostgreSQL</span> 对于任何只包含日期或时间的类型，都会假定其使用本地时区。</p>\n<p lang=\"zh\">所有带时区的日期和时间都在内部以 UTC 存储。显示给客户端之前，它们会转换为 TimeZone 配置参数指定时区的本地时间。</p>\n<p lang=\"zh\"><span class=\"productname\">PostgreSQL</span> 允许使用三种不同形式来指定时区：</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p>完整时区名称，例如 <code class=\"literal\">America/New_York</code>。识别到的时区名称列在 <code class=\"literal\">pg_timezone_names</code> 视图中（见<a class=\"xref\" href=\"/docs/18/view-pg-timezone-names.html\" title=\"53.34. pg_timezone_names\">第 53.34 节</a>）。<span class=\"productname\">PostgreSQL</span> 为此使用广泛采用的 IANA 时区数据，因此同样的时区名称通常也会被其他软件识别。</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>时区缩写，例如 <code class=\"literal\">PST</code>。与完整时区名称不同，这种指定方式只定义了一个特定的 UTC 偏移，而完整时区名称还可能隐含一套夏令时切换规则。识别到的缩写列在 <code class=\"literal\">pg_timezone_abbrevs</code> 视图中（见<a class=\"xref\" href=\"/docs/18/view-pg-timezone-abbrevs.html\" title=\"53.33. pg_timezone_abbrevs\">第 53.33 节</a>）。你不能把<a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-TIMEZONE\">TimeZone</a>或<a class=\"xref\" href=\"/docs/18/runtime-config-logging.html#GUC-LOG-TIMEZONE\">log_timezone</a>配置参数设置为时区缩写，但可以在日期/时间输入值中以及与 <code class=\"literal\">AT TIME ZONE</code> 操作符一起使用缩写。</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p>除了时区名称和缩写之外，<span class=\"productname\">PostgreSQL</span> 还接受 POSIX 风格的时区说明，见<a class=\"xref\" href=\"/docs/18/datetime-posix-timezone-specs.html\" title=\"B.5. POSIX 时区规范\">第 B.5 节</a>。这个选项通常不如使用具名时区更合适，但如果没有合适的 IANA 时区条目可用，它可能就是必需的。</p>\n</li>\n</ul>\n</div>\n<p lang=\"zh\">简而言之，这就是缩写和全名的区别：缩写表示某个特定的 UTC 偏移，而很多完整名称隐含了当地的夏令时规则，因此可能对应两个不同的 UTC 偏移。例如，<code class=\"literal\">2014-06-04 12:00 America/New_York</code> 表示纽约当地时间中午；在这个具体日期，它属于东部夏令时（UTC-4），所以 <code class=\"literal\">2014-06-04 12:00 EDT</code> 指定的是同一个时刻。但 <code class=\"literal\">2014-06-04 12:00 EST</code> 指定的是东部标准时中午（UTC-5），无论当天名义上是否正在实行夏令时。</p>\n<div class=\"note\">\n<h3 class=\"title\" lang=\"zh\">注意</h3>\n<p lang=\"zh\">POSIX 风格时区指定中的正负号，与 ISO-8601 日期时间值中的正负号含义相反。例如，2014-06-04 12:00+04 对应的 POSIX 时区是 UTC-4。</p>\n</div>\n<p lang=\"zh\">更复杂的是，一些司法辖区在不同时间使用同一时区缩写来表示不同的 UTC 偏移；例如在莫斯科，<code class=\"literal\">MSK</code> 在某些年份表示 UTC+3，在另一些年份则表示 UTC+4。<span class=\"productname\">PostgreSQL</span> 会按照该缩写在所给日期上的含义（或最近一次的含义）来解释这类缩写；但与上面的 <code class=\"literal\">EST</code> 例子一样，这并不一定等同于该日期的当地民用时间。</p>\n<p lang=\"zh\">无论哪种形式，时区名称及其缩写都不区分大小写。（这是对 <span class=\"productname\">PostgreSQL</span> 8.2 之前版本的一项改动；在那些版本中，时区名在某些环境下区分大小写，而在另一些环境下则不区分。）</p>\n<p lang=\"zh\">时区名称和缩写并不是硬编码在服务器中的；它们来自安装目录下 <code class=\"filename\">.../share/timezone/</code> 和 <code class=\"filename\">.../share/timezonesets/</code> 子目录中的配置文件（见<a class=\"xref\" href=\"/docs/18/datetime-config-files.html\" title=\"B.4. 日期/时间配置文件\">第 B.4 节</a>）。</p>\n<p lang=\"zh\"><a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-TIMEZONE\">TimeZone</a>配置参数可以在 <code class=\"filename\">postgresql.conf</code> 文件中设置，也可以通过<a class=\"xref\" href=\"/docs/18/runtime-config.html\" title=\"第 19 章 服务器配置\">第 19 章</a>中说明的其他标准方式设置。另外，还有一些特殊的设置方法：</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\" lang=\"zh\">\n<p><acronym class=\"acronym\">SQL</acronym> 命令 <code class=\"command\">SET TIME ZONE</code> 用于设置会话的时区。它是 <code class=\"command\">SET TIMEZONE TO</code> 的另一种写法，语法上更符合 SQL 规范。</p>\n</li>\n<li class=\"listitem\" lang=\"zh\">\n<p><code class=\"envar\">PGTZ</code> 环境变量会被 <span class=\"application\">libpq</span> 客户端用于在连接到服务器时发送一条 <code class=\"command\">SET TIME ZONE</code> 命令。</p>\n</li>\n</ul>\n</div>\n</div>\n<div class=\"sect2\" id=\"DATATYPE-INTERVAL-INPUT\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h3 class=\"title\" lang=\"zh\"><span class=\"sect2\"><a href=\"/docs/18/datatype-datetime.html#DATATYPE-INTERVAL-INPUT\">8.5.4. 间隔输入</a></span></h3>\n</div>\n</div>\n</div>\n<p lang=\"zh\"><code class=\"type\">interval</code>值可以使用下列详细语法书写：</p>\n<pre class=\"synopsis\">[<span class=\"optional\">@</span>] <em class=\"replaceable\"><code>quantity</code></em> <em class=\"replaceable\"><code>unit</code></em> [<span class=\"optional\"><em class=\"replaceable\"><code>quantity</code></em> <em class=\"replaceable\"><code>unit</code></em>...</span>] [<span class=\"optional\"><em class=\"replaceable\"><code>direction</code></em></span>]\n</pre>\n<p lang=\"zh\">其中<em class=\"replaceable\"><code>quantity</code></em>是一个数字（可以带有符号）；<em class=\"replaceable\"><code>unit</code></em>是<code class=\"literal\">microsecond</code>、<code class=\"literal\">millisecond</code>、<code class=\"literal\">second</code>、<code class=\"literal\">minute</code>、<code class=\"literal\">hour</code>、<code class=\"literal\">day</code>、<code class=\"literal\">week</code>、<code class=\"literal\">month</code>、<code class=\"literal\">year</code>、<code class=\"literal\">decade</code>、<code class=\"literal\">century</code>、<code class=\"literal\">millennium</code> 或它们的缩写或复数形式；<em class=\"replaceable\"><code>direction</code></em> 可以是 <code class=\"literal\">ago</code> 或为空。at 符号（<code class=\"literal\">@</code>）只是可选的噪声。不同单位的数量会按适当的符号规则隐式相加。<code class=\"literal\">ago</code> 会将所有字段取反。如果<a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-INTERVALSTYLE\">IntervalStyle</a>被设置为 <code class=\"literal\">postgres_verbose</code>，该语法也会用于间隔输出。</p>\n<p lang=\"zh\">日、小时、分钟和秒的数量也可以不写显式单位标记。例如，<code class=\"literal\">'1 12:59:10'</code> 会被读作 <code class=\"literal\">'1 day 12 hours 59 min 10 sec'</code>。同样，年和月的组合也可以用一个连字符表示，例如 <code class=\"literal\">'200-10'</code> 会被读作 <code class=\"literal\">'200 years 10 months'</code>。（事实上，这些较短形式正是 <acronym class=\"acronym\">SQL</acronym> 标准唯一允许的形式，并且在 <code class=\"varname\">IntervalStyle</code> 被设置为 <code class=\"literal\">sql_standard</code> 时也用于输出。）</p>\n<p lang=\"zh\">间隔值也可以写成 ISO 8601 时间间隔，使用标准第 4.4.3.2 节的<span class=\"quote\">“<span class=\"quote\">带标志符的格式</span>”</span>，或第 4.4.3.3 节的<span class=\"quote\">“<span class=\"quote\">替代格式</span>”</span>。带标志符的格式如下：</p>\n<pre class=\"synopsis\">P <em class=\"replaceable\"><code>quantity</code></em> <em class=\"replaceable\"><code>unit</code></em> [<span class=\"optional\"> <em class=\"replaceable\"><code>quantity</code></em> <em class=\"replaceable\"><code>unit</code></em> ...</span>] [<span class=\"optional\"> T [<span class=\"optional\"> <em class=\"replaceable\"><code>quantity</code></em> <em class=\"replaceable\"><code>unit</code></em> ...</span>]</span>]\n</pre>\n<p lang=\"zh\">字符串必须以 <code class=\"literal\">P</code> 开头，并且可以包含一个 <code class=\"literal\">T</code> 来引出一天中的时间单位。可用的单位缩写见<a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-INTERVAL-ISO8601-UNITS\" title=\"表 8.16. ISO 8601 间隔单位缩写\">表 8.16</a>。单位可以省略，也可以按任意顺序出现，但小于一天的单位必须出现在 <code class=\"literal\">T</code> 之后。特别是，<code class=\"literal\">M</code> 的含义取决于它是在 <code class=\"literal\">T</code> 之前还是之后。</p>\n<div class=\"table\" id=\"DATATYPE-INTERVAL-ISO8601-UNITS\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.16. ISO 8601 间隔单位缩写</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">缩写</th>\n<th lang=\"zh\">含义</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Y</td>\n<td lang=\"zh\">年</td>\n</tr>\n<tr>\n<td>M</td>\n<td lang=\"zh\">月（在日期部分中）</td>\n</tr>\n<tr>\n<td>W</td>\n<td lang=\"zh\">周</td>\n</tr>\n<tr>\n<td>D</td>\n<td lang=\"zh\">日</td>\n</tr>\n<tr>\n<td>H</td>\n<td lang=\"zh\">小时</td>\n</tr>\n<tr>\n<td>M</td>\n<td lang=\"zh\">分钟（在时间部分中）</td>\n</tr>\n<tr>\n<td>S</td>\n<td lang=\"zh\">秒</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n<p lang=\"zh\">如果使用替代格式：</p>\n<pre class=\"synopsis\">P [<span class=\"optional\"> <em class=\"replaceable\"><code>years</code></em>-<em class=\"replaceable\"><code>months</code></em>-<em class=\"replaceable\"><code>days</code></em> </span>] [<span class=\"optional\"> T <em class=\"replaceable\"><code>hours</code></em>:<em class=\"replaceable\"><code>minutes</code></em>:<em class=\"replaceable\"><code>seconds</code></em> </span>]\n</pre>\n<p lang=\"zh\">字符串必须以 P 开头，T 分隔时间间隔的日期部分和时间部分。各值采用类似 ISO 8601 日期的数字形式。</p>\n<p lang=\"zh\">当编写带有 <em class=\"replaceable\"><code>fields</code></em> 说明的间隔常量，或者把字符串赋给一个定义时带有 <em class=\"replaceable\"><code>fields</code></em> 说明的间隔列时，未标记数量的解释方式取决于 <em class=\"replaceable\"><code>fields</code></em>。例如，<code class=\"literal\">INTERVAL '1' YEAR</code> 会被读作 1 年，而 <code class=\"literal\">INTERVAL '1'</code> 表示 1 秒。此外，位于 <em class=\"replaceable\"><code>fields</code></em> 说明所允许的最小字段<span class=\"quote\">“<span class=\"quote\">右侧</span>”</span>的字段值会被静默丢弃。例如，写 <code class=\"literal\">INTERVAL '1 day 2:03:04' HOUR TO MINUTE</code> 会导致秒字段被丢弃，而不是日字段。</p>\n<p lang=\"zh\">根据 <acronym class=\"acronym\">SQL</acronym> 标准，一个间隔值的所有字段都必须带有相同符号，因此一个前导负号会作用于所有字段；例如间隔字面值 <code class=\"literal\">'-1 2:03:04'</code> 中的负号会同时作用于日、小时、分钟和秒。<span class=\"productname\">PostgreSQL</span> 允许各字段具有不同符号，并且传统上认为文本表示中的每个字段都带有各自独立的符号，因而在这个例子里，小时、分钟和秒部分会被视为正值。如果 <code class=\"varname\">IntervalStyle</code> 被设置为 <code class=\"literal\">sql_standard</code>，则会把前导符号视为作用于所有字段（但前提是没有出现额外符号）；否则将采用传统的 <span class=\"productname\">PostgreSQL</span> 解释。为了避免混淆，我们建议只要有任何字段为负值，就为每个字段都显式写出符号。</p>\n<p lang=\"zh\">在内部，<code class=\"type\">interval</code> 值以三个整数字段存储：月、日和微秒。之所以将它们分开保存，是因为一个月中的天数会变化，而如果涉及夏令时切换，一天也可能只有 23 或 25 小时。使用其他单位的间隔输入字符串会先规范化为这种格式，然后再以标准化方式重建输出，例如：</p>\n<pre class=\"programlisting\">SELECT '2 years 15 months 100 weeks 99 hours 123456789 milliseconds'::interval;\n               interval\n---------------------------------------\n 3 years 3 mons 700 days 133:17:36.789\n</pre>\n<p lang=\"zh\">这里，周按<span class=\"quote\">“<span class=\"quote\">7 天</span>”</span>计算并单独保留，而较小和较大的时间单位则被合并并规范化了。</p>\n<p lang=\"zh\">输入字段值可以带有小数部分，例如 <code class=\"literal\">'1.5 weeks'</code> 或 <code class=\"literal\">'01:02:03.45'</code>。然而，由于 <code class=\"type\">interval</code> 在内部只存储整数字段，小数值必须转换成更小的单位。大于月的单位的小数部分会被舍入为整数个月，例如 <code class=\"literal\">'1.5 years'</code> 会变成 <code class=\"literal\">'1 year 6 mons'</code>。周和天的小数部分会在假定每月 30 天、每天 24 小时的前提下，计算成整数天和微秒，例如 <code class=\"literal\">'1.75 months'</code> 会变成 <code class=\"literal\">1 mon 22 days 12:00:00</code>。只有秒在输出时才可能显示为小数。</p>\n<p lang=\"zh\"><a class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-INTERVAL-INPUT-EXAMPLES\" title=\"表 8.17. 间隔输入\">表 8.17</a>展示了一些有效<code class=\"type\">interval</code>输入的示例。</p>\n<div class=\"table\" id=\"DATATYPE-INTERVAL-INPUT-EXAMPLES\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.17. 间隔输入</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">示例</th>\n<th lang=\"zh\">说明</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"literal\">1-2</code></td>\n<td lang=\"zh\">SQL 标准格式：1 年 2 个月</td>\n</tr>\n<tr>\n<td><code class=\"literal\">3 4:05:06</code></td>\n<td lang=\"zh\">SQL 标准格式：3 天 4 小时 5 分钟 6 秒</td>\n</tr>\n<tr>\n<td><code class=\"literal\">1 year 2 months 3 days 4 hours 5 minutes 6 seconds</code></td>\n<td lang=\"zh\">传统 Postgres 格式：1 年 2 个月 3 天 4 小时 5 分钟 6 秒</td>\n</tr>\n<tr>\n<td><code class=\"literal\">P1Y2M3DT4H5M6S</code></td>\n<td lang=\"zh\">ISO 8601 <span class=\"quote\">“<span class=\"quote\">带标志符的格式</span>”</span>：含义同上</td>\n</tr>\n<tr>\n<td><code class=\"literal\">P0001-02-03T04:05:06</code></td>\n<td lang=\"zh\">ISO 8601 的<span class=\"quote\">“<span class=\"quote\">替代格式</span>”</span>：含义同上</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n</div>\n<div class=\"sect2\" id=\"DATATYPE-INTERVAL-OUTPUT\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h3 class=\"title\" lang=\"zh\"><span class=\"sect2\"><a href=\"/docs/18/datatype-datetime.html#DATATYPE-INTERVAL-OUTPUT\">8.5.5. 间隔输出</a></span></h3>\n</div>\n</div>\n</div>\n<p lang=\"zh\">如前所述，PostgreSQL 将 interval 值存储为月、日和微秒。输出时，月份字段通过除以 12 转换为年和月；天数字段原样显示；微秒字段转换为时、分、秒和小数秒。因此，月、分、秒的显示值分别不会超出 0–11、0–59 和 0–59 的范围，而年、日、时的显示值则可以很大。（若希望将较大的天数或小时数折算到更高一级字段，可使用 justify_days 和 justify_hours 函数。）</p>\n<p lang=\"zh\">可使用 SET intervalstyle 将 interval 的输出格式设为 sql_standard、postgres、postgres_verbose 或 iso_8601 四种风格之一，默认为 postgres。表 8.18 给出了各输出风格的示例。</p>\n<p lang=\"zh\">如果间隔值满足 SQL 标准的限制条件（仅有年-月或仅有日-时间，且不混合正负分量），<code class=\"literal\">sql_standard</code> 风格会生成符合 SQL 标准的间隔字面值输出。否则，输出将表现为一个标准的年-月字面值串后跟一个日-时间字面值串，并显式加上符号，以消除正负混合间隔的歧义。</p>\n<p lang=\"zh\"><code class=\"literal\">postgres</code> 样式的输出与 <span class=\"productname\">PostgreSQL</span> 8.4 之前版本在<a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-DATESTYLE\">DateStyle</a>参数设为 <code class=\"literal\">ISO</code> 时的输出一致。</p>\n<p lang=\"zh\"><code class=\"literal\">postgres_verbose</code> 样式的输出与 <span class=\"productname\">PostgreSQL</span> 8.4 之前版本在 <code class=\"varname\">DateStyle</code> 参数设为非 <code class=\"literal\">ISO</code> 输出时的结果一致。</p>\n<p lang=\"zh\"><code class=\"literal\">iso_8601</code> 风格的输出符合 ISO 8601 标准 4.4.3.2 节描述的<span class=\"quote\">“<span class=\"quote\">带标志符的格式</span>”</span>。</p>\n<div class=\"table\" id=\"INTERVAL-STYLE-OUTPUT-TABLE\">\n<p class=\"title\" lang=\"zh\"><strong>表 8.18. 间隔输出风格示例</strong></p>\n<div class=\"table-contents\">\n<table class=\"table\">\n<thead>\n<tr>\n<th lang=\"zh\">风格设置</th>\n<th lang=\"zh\">年-月间隔</th>\n<th lang=\"zh\">日-时间间隔</th>\n<th lang=\"zh\">混合间隔</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"literal\">sql_standard</code></td>\n<td>1-2</td>\n<td>3 4:05:06</td>\n<td>-1-2 +3 -4:05:06</td>\n</tr>\n<tr>\n<td><code class=\"literal\">postgres</code></td>\n<td>1 year 2 mons</td>\n<td>3 days 04:05:06</td>\n<td>-1 year -2 mons +3 days -04:05:06</td>\n</tr>\n<tr>\n<td><code class=\"literal\">postgres_verbose</code></td>\n<td>@ 1 year 2 mons</td>\n<td>@ 3 days 4 hours 5 mins 6 secs</td>\n<td>@ 1 year 2 mons -3 days 4 hours 5 mins 6 secs ago</td>\n</tr>\n<tr>\n<td><code class=\"literal\">iso_8601</code></td>\n<td>P1Y2M</td>\n<td>P3DT4H5M6S</td>\n<td>P-1Y-2M3D​T-4H-5M-6S</td>\n</tr>\n</tbody>\n</table>\n</div>\n</div><br class=\"table-break\"/>\n</div>\n</div>", "manual_path": "datatype-datetime.html", "localization": {"status": "complete", "sources": [{"url": "/docs/18/datatype-datetime.html", "method": "same-major semantic node", "sha256": "759b11dcb19826d862d531f3f01e6ad5cfc1a27e37bf5d6ecbf48085a4cf8252", "language": "zh", "matched_nodes": ["#DATATYPE-DATETIME/div[0]", "#DATATYPE-DATETIME/div[13]/div[1]/table[0]/tbody[2]/tr[0]/td[2]", "#DATATYPE-DATETIME/div[13]/div[1]/table[0]/tbody[2]/tr[1]/td[2]", "#DATATYPE-DATETIME/div[13]/div[1]/table[0]/tbody[2]/tr[2]/td[2]", "#DATATYPE-DATETIME/div[13]/div[1]/table[0]/tbody[2]/tr[3]/td[2]", "#DATATYPE-DATETIME/div[13]/div[1]/table[0]/tbody[2]/tr[4]/td[2]", "#DATATYPE-DATETIME/div[13]/div[1]/table[0]/tbody[2]/tr[5]/td[2]", "#DATATYPE-DATETIME/div[13]/div[1]/table[0]/thead[1]/tr[0]/th[0]", "#DATATYPE-DATETIME/div[13]/p[0]", "#DATATYPE-DATETIME/div[15]/h3[0]", "#DATATYPE-DATETIME/div[15]/p[1]", "#DATATYPE-DATETIME/div[1]/dl[0]/dt[0]", "#DATATYPE-DATETIME/div[1]/dl[0]/dt[1]", "#DATATYPE-DATETIME/div[1]/dl[0]/dt[2]", "#DATATYPE-DATETIME/div[1]/dl[0]/dt[3]", "#DATATYPE-DATETIME/div[1]/dl[0]/dt[4]", "#DATATYPE-DATETIME/div[21]/div[6]/div[0]", "#DATATYPE-DATETIME/div[21]/div[6]/div[3]/div[1]/table[0]/tbody[2]/tr[13]/td[1]", "#DATATYPE-DATETIME/div[21]/div[6]/div[3]/div[1]/table[0]/tbody[2]/tr[14]/td[1]", "#DATATYPE-DATETIME/div[21]/div[6]/div[3]/div[1]/table[0]/tbody[2]/tr[1]/td[1]", "#DATATYPE-DATETIME/div[21]/div[6]/div[3]/div[1]/table[0]/thead[1]/tr[0]/th[0]", "#DATATYPE-DATETIME/div[21]/div[6]/div[3]/p[0]", "#DATATYPE-DATETIME/div[21]/div[6]/p[2]", "#DATATYPE-DATETIME/div[21]/div[7]/div[0]", "#DATATYPE-DATETIME/div[21]/div[7]/div[6]/div[1]/table[0]/tbody[2]/tr[10]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[6]/div[1]/table[0]/tbody[2]/tr[12]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[6]/div[1]/table[0]/tbody[2]/tr[13]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[6]/div[1]/table[0]/tbody[2]/tr[6]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[6]/p[0]", "#DATATYPE-DATETIME/div[21]/div[7]/div[8]/div[1]/table[0]/tbody[2]/tr[0]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[8]/div[1]/table[0]/tbody[2]/tr[1]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[8]/div[1]/table[0]/tbody[2]/tr[2]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[8]/div[1]/table[0]/tbody[2]/tr[3]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[8]/div[1]/table[0]/tbody[2]/tr[7]/td[1]", "#DATATYPE-DATETIME/div[21]/div[7]/div[8]/p[0]", "#DATATYPE-DATETIME/div[21]/div[7]/p[10]", "#DATATYPE-DATETIME/div[21]/div[7]/p[4]", "#DATATYPE-DATETIME/div[21]/div[7]/p[5]", "#DATATYPE-DATETIME/div[21]/div[8]/div[0]", "#DATATYPE-DATETIME/div[21]/div[8]/p[10]", "#DATATYPE-DATETIME/div[21]/div[8]/p[11]", "#DATATYPE-DATETIME/div[21]/div[8]/p[13]", "#DATATYPE-DATETIME/div[21]/div[8]/p[15]", "#DATATYPE-DATETIME/div[21]/div[8]/p[17]", "#DATATYPE-DATETIME/div[21]/div[8]/p[18]", "#DATATYPE-DATETIME/div[21]/div[8]/p[19]", "#DATATYPE-DATETIME/div[21]/div[8]/p[20]", "#DATATYPE-DATETIME/div[21]/div[8]/p[4]", "#DATATYPE-DATETIME/div[21]/div[8]/p[6]", "#DATATYPE-DATETIME/div[21]/div[8]/p[8]", "#DATATYPE-DATETIME/div[21]/div[9]/div[0]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/tbody[2]/tr[0]/td[2]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/tbody[2]/tr[1]/td[2]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/tbody[2]/tr[2]/td[2]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/tbody[2]/tr[3]/td[2]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/tbody[2]/tr[4]/td[2]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/tbody[2]/tr[5]/td[2]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/tbody[2]/tr[6]/td[2]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/thead[1]/tr[0]/th[0]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/div[1]/table[0]/thead[1]/tr[0]/th[1]", "#DATATYPE-DATETIME/div[21]/div[9]/div[4]/p[0]", "#DATATYPE-DATETIME/div[21]/div[9]/div[7]/h3[0]", "#DATATYPE-DATETIME/div[21]/div[9]/div[7]/p[1]", "#DATATYPE-DATETIME/div[21]/div[9]/p[3]", "#DATATYPE-DATETIME/div[21]/p[2]", "#DATATYPE-DATETIME/div[21]/p[3]", "#DATATYPE-DATETIME/div[22]/div[4]/div[1]/table[0]/tbody[2]/tr[0]/td[1]", "#DATATYPE-DATETIME/div[22]/div[4]/div[1]/table[0]/tbody[2]/tr[1]/td[1]", "#DATATYPE-DATETIME/div[22]/div[4]/div[1]/table[0]/tbody[2]/tr[2]/td[1]", "#DATATYPE-DATETIME/div[22]/div[4]/div[1]/table[0]/tbody[2]/tr[3]/td[1]", "#DATATYPE-DATETIME/div[22]/div[4]/div[1]/table[0]/thead[1]/tr[0]/th[0]", "#DATATYPE-DATETIME/div[22]/div[4]/p[0]", "#DATATYPE-DATETIME/div[22]/div[8]/div[1]/table[0]/thead[1]/tr[0]/th[0]", "#DATATYPE-DATETIME/div[22]/div[8]/div[1]/table[0]/thead[1]/tr[0]/th[1]", "#DATATYPE-DATETIME/div[22]/div[8]/div[1]/table[0]/thead[1]/tr[0]/th[2]", "#DATATYPE-DATETIME/div[22]/div[8]/p[0]", "#DATATYPE-DATETIME/div[22]/p[10]", "#DATATYPE-DATETIME/div[22]/p[11]", "#DATATYPE-DATETIME/div[22]/p[12]", "#DATATYPE-DATETIME/div[22]/p[3]", "#DATATYPE-DATETIME/div[22]/p[7]", "#DATATYPE-DATETIME/div[23]/div[15]/ul[0]/li[0]", "#DATATYPE-DATETIME/div[23]/div[15]/ul[0]/li[1]", "#DATATYPE-DATETIME/div[23]/div[4]/ul[0]/li[0]", "#DATATYPE-DATETIME/div[23]/div[8]/ul[0]/li[0]", "#DATATYPE-DATETIME/div[23]/div[8]/ul[0]/li[1]", "#DATATYPE-DATETIME/div[23]/div[8]/ul[0]/li[2]", "#DATATYPE-DATETIME/div[23]/p[11]", "#DATATYPE-DATETIME/div[23]/p[12]", "#DATATYPE-DATETIME/div[23]/p[13]", "#DATATYPE-DATETIME/div[23]/p[14]", "#DATATYPE-DATETIME/div[23]/p[3]", "#DATATYPE-DATETIME/div[23]/p[5]", "#DATATYPE-DATETIME/div[23]/p[7]", "#DATATYPE-DATETIME/div[23]/p[9]", "#DATATYPE-DATETIME/div[24]/div[21]/div[1]/table[0]/tbody[2]/tr[3]/td[1]", "#DATATYPE-DATETIME/div[24]/div[21]/div[1]/table[0]/tbody[2]/tr[4]/td[1]", "#DATATYPE-DATETIME/div[24]/div[21]/p[0]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/tbody[2]/tr[0]/td[1]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/tbody[2]/tr[1]/td[1]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/tbody[2]/tr[2]/td[1]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/tbody[2]/tr[3]/td[1]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/tbody[2]/tr[4]/td[1]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/tbody[2]/tr[5]/td[1]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/tbody[2]/tr[6]/td[1]", "#DATATYPE-DATETIME/div[24]/div[9]/div[1]/table[0]/thead[1]/tr[0]/th[0]", "#DATATYPE-DATETIME/div[24]/div[9]/p[0]", "#DATATYPE-DATETIME/div[24]/p[11]", "#DATATYPE-DATETIME/div[24]/p[14]", "#DATATYPE-DATETIME/div[24]/p[15]", "#DATATYPE-DATETIME/div[24]/p[16]", "#DATATYPE-DATETIME/div[24]/p[18]", "#DATATYPE-DATETIME/div[24]/p[19]", "#DATATYPE-DATETIME/div[24]/p[20]", "#DATATYPE-DATETIME/div[24]/p[2]", "#DATATYPE-DATETIME/div[24]/p[4]", "#DATATYPE-DATETIME/div[24]/p[5]", "#DATATYPE-DATETIME/div[24]/p[6]", "#DATATYPE-DATETIME/div[24]/p[8]", "#DATATYPE-DATETIME/div[25]/div[8]/div[1]/table[0]/thead[1]/tr[0]/th[1]", "#DATATYPE-DATETIME/div[25]/div[8]/div[1]/table[0]/thead[1]/tr[0]/th[2]", "#DATATYPE-DATETIME/div[25]/div[8]/div[1]/table[0]/thead[1]/tr[0]/th[3]", "#DATATYPE-DATETIME/div[25]/div[8]/p[0]", "#DATATYPE-DATETIME/div[25]/p[4]", "#DATATYPE-DATETIME/div[25]/p[5]", "#DATATYPE-DATETIME/div[25]/p[6]", "#DATATYPE-DATETIME/div[25]/p[7]", "#DATATYPE-DATETIME/p[12]", "#DATATYPE-DATETIME/p[17]", "#DATATYPE-DATETIME/p[19]", "#DATATYPE-DATETIME/p[20]"]}, {"url": "/docs/18/datatype-money.html", "method": "same-major semantic node", "sha256": "6a3a18c17225f00376744bdae7a7f782102e9a0cce0bc2491e7669a43283455e", "language": "zh", "matched_nodes": ["#DATATYPE-MONEY/div[2]/div[1]/table[0]/tbody[2]/tr[0]/td[1]"]}, {"url": "/docs/18/datatype-numeric.html", "method": "same-major semantic node", "sha256": "3119f68768634c1b35c2d9fb65ecb989addbdf99d88064c8292f114cf3b2b79d", "language": "zh", "matched_nodes": ["#DATATYPE-NUMERIC/div[8]/p[29]/span[0]/span[0]"]}], "language": "zh", "original_text": {"/versions/18/description/0": "date and time (no time zone)", "/versions/18/facts/0/label": "Catalog name", "/versions/18/facts/1/label": "Type OID", "/versions/18/facts/2/label": "Type kind", "/versions/18/facts/2/value": "Base type", "/versions/18/facts/3/label": "Declared length", "/versions/18/facts/3/value": "8 bytes", "/versions/18/facts/4/label": "Storage strategy", "/versions/18/facts/5/label": "Input function", "/versions/18/facts/6/label": "Output function", "/versions/18/facts/7/label": "Documented declaration", "/versions/18/facts/8/label": "Storage Size", "/versions/18/facts/8/value": "8 bytes", "/versions/18/facts/9/label": "Manual description", "/versions/18/facts/9/value": "both date and time (no time zone)", "/versions/18/facts/10/label": "Low Value", "/versions/18/facts/10/value": "4713 BC", "/versions/18/facts/11/label": "High Value", "/versions/18/facts/11/value": "294276 AD", "/versions/18/facts/12/label": "Resolution", "/versions/18/facts/12/value": "1 microsecond", "/versions/18/related/0/label": "pg_type catalog", "/versions/18/related/1/label": "pg_cast catalog", "/versions/18/related/2/label": "pg_operator catalog", "/versions/18/related/3/label": "pg_opclass catalog", "/versions/18/related/4/label": "Arrays", "/versions/18/related/5/label": "brin index access method", "/versions/18/related/6/label": "btree index access method", "/versions/18/related/7/label": "hash index access method"}, "fallback_fields": [], "source_language": "en", "original_snapshot_sha256": "e016d116d65ab42f9cfa7c69339b5b76539e661fb9b4d22e0c4f8b379d3eb8d8"}, "comparison_data": {"casts": [{"castfunc": "date(timestamp)", "castmethod": "f", "castsource": "timestamp", "casttarget": "date", "castcontext": "a"}, {"castfunc": "time(timestamp)", "castmethod": "f", "castsource": "timestamp", "casttarget": "time", "castcontext": "a"}, {"castfunc": "timestamp(timestamptz)", "castmethod": "f", "castsource": "timestamptz", "casttarget": "timestamp", "castcontext": "a"}, {"castfunc": "timestamp(date)", "castmethod": "f", "castsource": "date", "casttarget": "timestamp", "castcontext": "i"}, {"castfunc": "timestamp(timestamp,int4)", "castmethod": "f", "castsource": "timestamp", "casttarget": "timestamp", "castcontext": "i"}, {"castfunc": "timestamptz(timestamp)", "castmethod": "f", "castsource": "timestamp", "casttarget": "timestamptz", "castcontext": "i"}], "facts": [{"label": "Catalog name", "value": "pg_catalog.timestamp"}, {"label": "Declared length", "value": "8 bytes"}, {"label": "Documented declaration", "value": "timestamp [ ( p ) ] [ without time zone ]"}, {"label": "High Value", "value": "294276 AD"}, {"label": "Input function", "value": "timestamp_in"}, {"label": "Low Value", "value": "4713 BC"}, {"label": "Output function", "value": "timestamp_out"}, {"label": "Resolution", "value": "1 microsecond"}, {"label": "Storage Size", "value": "8 bytes"}, {"label": "Storage strategy", "value": "plain"}, {"label": "Type OID", "value": "1114"}, {"label": "Type kind", "value": "Base type"}], "ranges": [], "aliases": ["timestamp"], "catalog": {"typacl": "_null_", "typlen": "8", "typelem": "0", "typname": "timestamp", "typsend": "timestamp_send", "typtype": "b", "typalign": "d", "typarray": "_timestamp", "typbyval": "FLOAT8PASSBYVAL", "typdelim": ",", "typinput": "timestamp_in", "typmodin": "timestamptypmodin", "typndims": "0", "typrelid": "0", "typmodout": "timestamptypmodout", "typoutput": "timestamp_out", "typtypmod": "-1", "typanalyze": "-", "typdefault": "_null_", "typnotnull": "f", "typreceive": "timestamp_recv", "typstorage": "p", "typbasetype": "0", "typcategory": "D", "typcollation": "0", "typisdefined": "t", "typsubscript": "-", "typdefaultbin": "_null_", "typispreferred": "f", "array_type_name": "_timestamp"}, "operators": [{"oprcom": "<=(timestamp,date)", "oprcode": "date_ge_timestamp", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "date", "oprname": ">=", "oprrest": "scalargesel", "oprright": "timestamp", "oprnegate": "<(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<(timestamp,date)", "oprcode": "date_gt_timestamp", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "date", "oprname": ">", "oprrest": "scalargtsel", "oprright": "timestamp", "oprnegate": "<=(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">=(timestamp,date)", "oprcode": "date_le_timestamp", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "date", "oprname": "<=", "oprrest": "scalarlesel", "oprright": "timestamp", "oprnegate": ">(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">(timestamp,date)", "oprcode": "date_lt_timestamp", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "date", "oprname": "<", "oprrest": "scalarltsel", "oprright": "timestamp", "oprnegate": ">=(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<>(timestamp,date)", "oprcode": "date_ne_timestamp", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "date", "oprname": "<>", "oprrest": "neqsel", "oprright": "timestamp", "oprnegate": "=(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "+(timestamp,interval)", "oprcode": "interval_pl_timestamp", "oprjoin": "-", "oprkind": "b", "oprleft": "interval", "oprname": "+", "oprrest": "-", "oprright": "timestamp", "oprnegate": "0", "oprresult": "timestamp", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<=(timestamp,timestamp)", "oprcode": "timestamp_ge", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">=", "oprrest": "scalargesel", "oprright": "timestamp", "oprnegate": "<(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<=(date,timestamp)", "oprcode": "timestamp_ge_date", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">=", "oprrest": "scalargesel", "oprright": "date", "oprnegate": "<(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<=(timestamptz,timestamp)", "oprcode": "timestamp_ge_timestamptz", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">=", "oprrest": "scalargesel", "oprright": "timestamptz", "oprnegate": "<(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<(timestamp,timestamp)", "oprcode": "timestamp_gt", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">", "oprrest": "scalargtsel", "oprright": "timestamp", "oprnegate": "<=(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<(date,timestamp)", "oprcode": "timestamp_gt_date", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">", "oprrest": "scalargtsel", "oprright": "date", "oprnegate": "<=(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<(timestamptz,timestamp)", "oprcode": "timestamp_gt_timestamptz", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": ">", "oprrest": "scalargtsel", "oprright": "timestamptz", "oprnegate": "<=(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">=(timestamp,timestamp)", "oprcode": "timestamp_le", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<=", "oprrest": "scalarlesel", "oprright": "timestamp", "oprnegate": ">(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">=(date,timestamp)", "oprcode": "timestamp_le_date", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<=", "oprrest": "scalarlesel", "oprright": "date", "oprnegate": ">(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">=(timestamptz,timestamp)", "oprcode": "timestamp_le_timestamptz", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<=", "oprrest": "scalarlesel", "oprright": "timestamptz", "oprnegate": ">(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">(timestamp,timestamp)", "oprcode": "timestamp_lt", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<", "oprrest": "scalarltsel", "oprright": "timestamp", "oprnegate": ">=(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">(date,timestamp)", "oprcode": "timestamp_lt_date", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<", "oprrest": "scalarltsel", "oprright": "date", "oprnegate": ">=(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">(timestamptz,timestamp)", "oprcode": "timestamp_lt_timestamptz", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<", "oprrest": "scalarltsel", "oprright": "timestamptz", "oprnegate": ">=(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "0", "oprcode": "timestamp_mi", "oprjoin": "-", "oprkind": "b", "oprleft": "timestamp", "oprname": "-", "oprrest": "-", "oprright": "timestamp", "oprnegate": "0", "oprresult": "interval", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "0", "oprcode": "timestamp_mi_interval", "oprjoin": "-", "oprkind": "b", "oprleft": "timestamp", "oprname": "-", "oprrest": "-", "oprright": "interval", "oprnegate": "0", "oprresult": "timestamp", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<>(timestamp,timestamp)", "oprcode": "timestamp_ne", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<>", "oprrest": "neqsel", "oprright": "timestamp", "oprnegate": "=(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<>(date,timestamp)", "oprcode": "timestamp_ne_date", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<>", "oprrest": "neqsel", "oprright": "date", "oprnegate": "=(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<>(timestamptz,timestamp)", "oprcode": "timestamp_ne_timestamptz", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "<>", "oprrest": "neqsel", "oprright": "timestamptz", "oprnegate": "=(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "+(interval,timestamp)", "oprcode": "timestamp_pl_interval", "oprjoin": "-", "oprkind": "b", "oprleft": "timestamp", "oprname": "+", "oprrest": "-", "oprright": "interval", "oprnegate": "0", "oprresult": "timestamp", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<=(timestamp,timestamptz)", "oprcode": "timestamptz_ge_timestamp", "oprjoin": "scalargejoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": ">=", "oprrest": "scalargesel", "oprright": "timestamp", "oprnegate": "<(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<(timestamp,timestamptz)", "oprcode": "timestamptz_gt_timestamp", "oprjoin": "scalargtjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": ">", "oprrest": "scalargtsel", "oprright": "timestamp", "oprnegate": "<=(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">=(timestamp,timestamptz)", "oprcode": "timestamptz_le_timestamp", "oprjoin": "scalarlejoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "<=", "oprrest": "scalarlesel", "oprright": "timestamp", "oprnegate": ">(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": ">(timestamp,timestamptz)", "oprcode": "timestamptz_lt_timestamp", "oprjoin": "scalarltjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "<", "oprrest": "scalarltsel", "oprright": "timestamp", "oprnegate": ">=(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "<>(timestamp,timestamptz)", "oprcode": "timestamptz_ne_timestamp", "oprjoin": "neqjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "<>", "oprrest": "neqsel", "oprright": "timestamp", "oprnegate": "=(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "f"}, {"oprcom": "=(timestamp,date)", "oprcode": "date_eq_timestamp", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "date", "oprname": "=", "oprrest": "eqsel", "oprright": "timestamp", "oprnegate": "<>(date,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t"}, {"oprcom": "=(date,timestamp)", "oprcode": "timestamp_eq_date", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "=", "oprrest": "eqsel", "oprright": "date", "oprnegate": "<>(timestamp,date)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t"}, {"oprcom": "=(timestamptz,timestamp)", "oprcode": "timestamp_eq_timestamptz", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "=", "oprrest": "eqsel", "oprright": "timestamptz", "oprnegate": "<>(timestamp,timestamptz)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t"}, {"oprcom": "=(timestamp,timestamptz)", "oprcode": "timestamptz_eq_timestamp", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamptz", "oprname": "=", "oprrest": "eqsel", "oprright": "timestamp", "oprnegate": "<>(timestamptz,timestamp)", "oprresult": "bool", "oprcanhash": "f", "oprcanmerge": "t"}, {"oprcom": "=(timestamp,timestamp)", "oprcode": "timestamp_eq", "oprjoin": "eqjoinsel", "oprkind": "b", "oprleft": "timestamp", "oprname": "=", "oprrest": "eqsel", "oprright": "timestamp", "oprnegate": "<>(timestamp,timestamp)", "oprresult": "bool", "oprcanhash": "t", "oprcanmerge": "t"}], "operator_classes": [{"opcname": "timestamp_bloom_ops", "opcfamily": "brin/datetime_bloom_ops", "opcintype": "timestamp", "opcmethod": "brin", "opcdefault": "f", "opckeytype": "timestamp"}, {"opcname": "timestamp_minmax_multi_ops", "opcfamily": "brin/datetime_minmax_multi_ops", "opcintype": "timestamp", "opcmethod": "brin", "opcdefault": "f", "opckeytype": "timestamp"}, {"opcname": "timestamp_minmax_ops", "opcfamily": "brin/datetime_minmax_ops", "opcintype": "timestamp", "opcmethod": "brin", "opcdefault": "t", "opckeytype": "timestamp"}, {"opcname": "timestamp_ops", "opcfamily": "btree/datetime_ops", "opcintype": "timestamp", "opcmethod": "btree", "opcdefault": "t", "opckeytype": "0"}, {"opcname": "timestamp_ops", "opcfamily": "hash/timestamp_ops", "opcintype": "timestamp", "opcmethod": "hash", "opcdefault": "t", "opckeytype": "0"}]}, "comparison_hash": "5775d1e4d6be453c075a9f7ac8a9cccdd076337795514c4b312da14359a64e28", "manual_language": "zh", "operator_classes": [{"oid": "3128", "opcname": "timestamp_ops", "opcowner": "POSTGRES", "opcfamily": "btree/datetime_ops", "opcintype": "timestamp", "opcmethod": "btree", "oid_symbol": "TIMESTAMP_BTREE_OPS_OID", "opcdefault": "t", "opckeytype": "0", "opcnamespace": "pg_catalog"}, {"opcname": "timestamp_ops", "opcowner": "POSTGRES", "opcfamily": "hash/timestamp_ops", "opcintype": "timestamp", "opcmethod": "hash", "opcdefault": "t", "opckeytype": "0", "opcnamespace": "pg_catalog"}, {"opcname": "timestamp_minmax_ops", "opcowner": "POSTGRES", "opcfamily": "brin/datetime_minmax_ops", "opcintype": "timestamp", "opcmethod": "brin", "opcdefault": "t", "opckeytype": "timestamp", "opcnamespace": "pg_catalog"}, {"opcname": "timestamp_minmax_multi_ops", "opcowner": "POSTGRES", "opcfamily": "brin/datetime_minmax_multi_ops", "opcintype": "timestamp", "opcmethod": "brin", "opcdefault": "f", "opckeytype": "timestamp", "opcnamespace": "pg_catalog"}, {"opcname": "timestamp_bloom_ops", "opcowner": "POSTGRES", "opcfamily": "brin/datetime_bloom_ops", "opcintype": "timestamp", "opcmethod": "brin", "opcdefault": "f", "opckeytype": "timestamp", "opcnamespace": "pg_catalog"}], "manual_documentation": "dedicated family chapter"}, "from": "17", "comparison": {"available": true, "changes": [], "prose_changed": true}}