Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFxp9-00078u-IO for pgsql-general@arkaria.postgresql.org; Thu, 12 Jan 2023 13:40:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFxp8-0001ER-7f for pgsql-general@arkaria.postgresql.org; Thu, 12 Jan 2023 13:40:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFxp7-0001EI-KK for pgsql-general@lists.postgresql.org; Thu, 12 Jan 2023 13:40:53 +0000 Received: from mx0c-001a4c01.pphosted.com ([67.231.158.153]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFxp4-0004DQ-1o for pgsql-general@lists.postgresql.org; Thu, 12 Jan 2023 13:40:52 +0000 Received: from pps.filterd (m0075701.ppops.net [127.0.0.1]) by mx0c-001a4c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30CAPqha022780 for ; Thu, 12 Jan 2023 08:40:47 -0500 Authentication-Results: ppops.net; spf=fail smtp.mailfrom=sebastien.flaesch@4js.com; dkim=pass header.d=ourvolaris.onmicrosoft.com header.s=selector2-ourvolaris-onmicrosoft-com Received: from eur05-db8-obe.outbound.protection.outlook.com (mail-db8eur05lp2109.outbound.protection.outlook.com [104.47.17.109]) by mx0c-001a4c01.pphosted.com (PPS) with ESMTPS id 3n1kbrghx8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 12 Jan 2023 08:40:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VeLRglt3ItI8qfaEb9gdi3xeMX2vsbCVXA+n86T7X17PxD7NCTTacwoJoh+BSBK3RMvjAxhv+gDaC0Nj+iu/6gDXD5ZWCPXAMpOKeIRS9EBez+An1hJZ3oouzq8yvmOuTQmPck0tP9zhdne1WoHMDpxk3izWsbg0euXiRT3fBkYHVaVFqetZwHX5R8wGsCiiJ3RWW7OzE3xpTDaUnF/RTP7bzOuvH6Td8va0zxAMCT/0Io1nnpTAZPfhIzbmdtw0lu4MoprvozJ2+8emvSS5dGJxPRmHw7bKkEShWxXNiFks3uIns3VbyMhjBWNDzIJPXILmP+5QmpsqLX4X76uoYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HXTOAREPXBcSU2DchIaKMFXf+sekVui3NIH7u+0CB8g=; b=SBsGP0Scjblu4caNmgiZoBPiT/zYuMhZfwQdnrmVOSsRiTQgu+Vnga0MioipKnTyKzshqB+j8COkvJ7yBJWm2EtcInI1l4S4pgs6gPnzxsykT/72Fd/YNXqcfWD7wgd7Yr0RdLGEf5K0lgU3ZUk1Q2EHJuwfI0qmhCDgJNwCiW3fdjpUngojlt2EfUQsS4rIhrEwcMVW9rX5lfhQYpYB7r4xse0QpBPMqR2uPWvfurECbpmBDY5S9TrbGUQRzB2fHYsM7jf1U3oWgdeSpLg8HG/57E4JaFC+G44I8EvFc4NPz5wSJbFLtezMHZuLtgC0Y9uGGOXZJfctT+ceyrxQIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=4js.com; dmarc=pass action=none header.from=4js.com; dkim=pass header.d=4js.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ourvolaris.onmicrosoft.com; s=selector2-ourvolaris-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HXTOAREPXBcSU2DchIaKMFXf+sekVui3NIH7u+0CB8g=; b=P108tGQgWhPwrJPh0uc1le2hxeAVqzPaT2RF8R7xC4A2F75YZs43qwKOPrWxHLRpy68ZD+fHUbpQ/asR7tYbJ+kAzwoVLkqQG9fzg+3Nj9BxeZbGXTkihGhiKq/zjFf17gxxX4SXUiPF96iVZf9QoyYwxyu0Vb/+eW1PhxYea8Y= Received: from AM9P191MB1286.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:1f2::22) by DB8P191MB1077.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:16e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 13:40:44 +0000 Received: from AM9P191MB1286.EURP191.PROD.OUTLOOK.COM ([fe80::a8fa:38d5:aeda:407a]) by AM9P191MB1286.EURP191.PROD.OUTLOOK.COM ([fe80::a8fa:38d5:aeda:407a%4]) with mapi id 15.20.5986.018; Thu, 12 Jan 2023 13:40:44 +0000 From: Sebastien Flaesch To: pgsql-general Subject: Intervals and ISO 8601 duration Thread-Topic: Intervals and ISO 8601 duration Thread-Index: AQHZJolIg4XgCo+lREiznlKudgz9nA== Date: Thu, 12 Jan 2023 13:40:43 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM9P191MB1286:EE_|DB8P191MB1077:EE_ x-ms-office365-filtering-correlation-id: 10bcb743-c09f-4fde-1f7d-08daf4a29a79 x-volarisppoutbound: true x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: bxa6X8ikUeKIUetJx+QpJsi9P28v+3LRJrDVnXhFcDI5TqOtB35/XTlJr9P2nUULP/xuHX+g9jJYIAQYcZ6nShJm6KN7Xtuuz4iSqiwJMUNshFM4WdrOysM3tVzENjZ6frEZJxPtF7nBRs7BssK084DCNO6hWj5Zk/KJCygfXZszHGB6/yJBXmM+NJ27jdAUS5p7cz3skq/oT8IBkL0o0qd7ZYsZm79/cYwJcyDido2yXREuj7LEpsvBFkSkjdgKzpvl2d2EwEdIbKgINDRnu5PVjVZadc1NvnPyUx/Bb8IZcDfRvd229pVu8UWxC0MJTl1ESB9dqtCgZ4elY4LGr6Hxnv8FIdYPDDefCRd8LoczVtKI+A+IfHDBgRr7hbCdXM8A7UVZs6cImDzxCKZeMavgtnS+HX97aPXNhg0XZ7VoHOozpqIbFuLv8U69L+DjurI0tjt1s5wL+9CHOOMUZyKcLenzfpqebD1dncGUgjPIM2iUmvJtDsoMiRbxPuVmAE4kHen4nNs5rDQu9onmIZ8S7qPl1vogLnKoffwlqRVupONC+rd0QCX1qxZZY55Ao/A7u8QyJceEtWU3ZJ9SaR3tWkyJRxxjYeVue8VBDq6XOGHNAJnqxHN0n6nk3SViYvVWTn7LKX8XFuENnGVl6ZE6GIGkBrscbOaFO/F0xvb2gfa41xmX+Bn+9Mz7zQfjK+dHN/kVnxYyLhFfC+5rJw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9P191MB1286.EURP191.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(366004)(376002)(39860400002)(451199015)(6506007)(2906002)(5660300002)(52536014)(8936002)(122000001)(44832011)(6916009)(64756008)(8676002)(19627405001)(66446008)(9686003)(38100700002)(41300700001)(33656002)(38070700005)(478600001)(91956017)(66556008)(66946007)(26005)(76116006)(186003)(7696005)(55016003)(66476007)(86362001)(71200400001)(316002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?umWJAX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J?= =?iso-8859-1?Q?EZ/dRbt1fVz1gwk4L7HBKJl+uhs7M/zGRDnp6jzATu+7Z8EshqiEol83OA?= =?iso-8859-1?Q?g+xV3TYyIhi7IxWeFH7WjYIPpzEJEyk9zugJYxyd8PRI4vmgAlzOTT+j4Z?= =?iso-8859-1?Q?NtE3AThAzSI/IUWPookdJ0q787waa/VIDpxel9L+Ps6ruYpDbSdNx1ylj3?= =?iso-8859-1?Q?jTWp28Kbq0Vprd6EYyhMovo5qlhtRcvej2H4JXmJewI874wSN4jKM161Qi?= =?iso-8859-1?Q?TNzZKr3bo9RvDfJTNycYAECXxdJTV1fyn4C8uVoVOjnFW/HRLRL7u/t47l?= =?iso-8859-1?Q?/r9fNyEcab8y2yJpu5IwezulNrjA5NjrbEZw6D6iK87Tam3KjJjOavb8yK?= =?iso-8859-1?Q?f4Zjq2nAcuvE9V2lfeOqJ68iBWfCS8Vo1NKZ0J9C/KNodVUSfp8M9VCFxA?= =?iso-8859-1?Q?Z7ut3A5UjGXoGAFvihT4OA94Oir94Tv2E5YoiUCCvSagsLPzuMCVsJMFbD?= =?iso-8859-1?Q?QxubSmEmsLNG9/DbZEqTBL1QOUg7FnQAiwMh5vudKJaDEPtSdEIaU9Y27T?= =?iso-8859-1?Q?i5Kz2E9MiZ2ml7DxWugisnRtmkRS7nVZ60BsOkXgwrRqTjWPgO1Qrg+5UV?= =?iso-8859-1?Q?1pphD/FAHQV1N2i9bqTbHeeejPCdUnCsnu2VJ82lPCCgtlef30+P51jh3T?= =?iso-8859-1?Q?efdNBkvy+y9Qre3e06voiUMgo1qAYII9C18muTQdBTp48dp5tvhTw35xzj?= =?iso-8859-1?Q?JF2Y0ldVhPw+vyo3/nTiIwzGQxzImUY2HZ?= Content-Type: multipart/alternative; boundary="_000_AM9P191MB1286AD77B5FBAF4640E7274AB0FD9AM9P191MB1286EURP_" MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9zd4BnZBqykHi9MfSJLigraG2tR++G0VTPwrW/ZjsfbF5xP3302l3XxHES5NnDxTxQe5MD2FA8NVUIj562E/2whYfPCwXBK6bLqF2CbT6QcbktkucKKNjkPKQ3XOzMUnDCDGKkCZP1ET2FqJkJuBs+ALiIrvap2XJp1Yb7hPON45a8llXRqN4b5qI1psq4w9nejoyZgq8xoBseyd9ejLt+4GRiCslXIlrm15FVzk2x6beeOuuIyPoy1BjZTgrGICi1cE5Jym3XpmXbRIzAQTeNwnnpFcC3QjoSpyy0NeDwpY1hu743C8miIIhk1CaGNhqmp0QvQOnqiOWZ38pjHWu2vYaiNWJx4nvWE5fMLZmG6yi5hHVsTYkk25YxCPi0LdFQeFzMlBoCBKtbF7V5vWoqRiJTPrarqXeAbwmuPnwy1aiZymN3JM2NgUuEI6ltJ1PyErwoRDUvf44RTlefadJHYz6QXmaaQWEAJ4aShOxVP5O+d5/JZF5ddSkVLz5mC3XsME8I5KiHfEXIDmjloCRjn/SddTzYNFeAFuSTHWjMT9AedoSlvCcFEx4iDsoPmZMiEJP2Z1cZ6OtyfLAwqkrUO/PwrDqTufNXIoYDQD4YmBv0zKB0Fv9HqcfQnceHLKTvsjpk+C/UZfSugnvIPbNLOSwNEkjH6crnOpreg1duC5Mf3D9L80zfpCAgZL8nhRc0UVtIciZn5JsWSZq0TRPJ0P5diBIfqrLb60seZV95RCTKNC6wnqKWGYPBnmB+dAHC/mBF2hRvyq1K//hZQOVNS7ylwRaQ04eL2OfavT0oiVfk1e6QdLXcVwx5Q4w/Qn X-OriginatorOrg: 4js.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM9P191MB1286.EURP191.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 10bcb743-c09f-4fde-1f7d-08daf4a29a79 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jan 2023 13:40:43.9230 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 75c696ec-5bfb-4892-9a0c-9187a9061cd6 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: A8eeAv+krvzXhACPyqL+broX/TSrTvO4FAKOItke8Vvoa28B5mu6C9/hxjGVPDnv+vUEI0ZaReFe1e7iD9NlKPocKY4Ddt1+o3D2lHTryUs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8P191MB1077 X-Proofpoint-ORIG-GUID: hUK9kgwtU6Hz4-fA3nkwdtQFm2sUaCuE X-Proofpoint-GUID: hUK9kgwtU6Hz4-fA3nkwdtQFm2sUaCuE X-ProofpointHeader: Yes X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 impostorscore=0 mlxlogscore=437 suspectscore=0 clxscore=1011 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120095 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_AM9P191MB1286AD77B5FBAF4640E7274AB0FD9AM9P191MB1286EURP_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable PostgreSQL has the INTERVAL type, which can be defined with fields such as: INTERVAL YEAR TO MONTH (year-month class) INTERVAL DAY TO SECOND(p) (day-second class) It's not possible to define an INTERVAL YEAR TO SECOND(p), which makes sens= e, since the number of days in a month can vary. Other SQL engines like Ora= cle and Informix also have 2 classes of interval types. However, the ISO-8601 standard format for durations allows to specify year/= month with day to second parts, for example: P2Y10M15DT10H30M20S Seems PostgreSQL accepts this format in input. But what does it mean exactly? What is the actual INTERVAL value and INTERVAL class of this? Testing with V15.1: What is the interval class in this case: test1=3D> select cast('P2Y10M15DT10H30M20S' as interval); interval ---------------------------------- 2 years 10 mons 15 days 10:30:20 (1 row) Should the following convert to a day-second interval? test1=3D> select cast('P2Y10M15DT10H30M20S' as interval day to second); interval ---------------------------------- 2 years 10 mons 15 days 10:30:20 (1 row) Should PostgreSQL not raise an SQL error in above cases? When using invalid INTERVAL fields, error is raised as expected: test1=3D> select cast('P2Y10M15DT10H30M20S' as interval year to second); ERROR: syntax error at or near "second" LINE 1: ...lect cast('P2Y10M15DT10H30M20S' as interval year to second); Does PostgreSQL assume that a month is ~30 days? I did not find details about this in the documentation. Thanks in advance! Seb --_000_AM9P191MB1286AD77B5FBAF4640E7274AB0FD9AM9P191MB1286EURP_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
PostgreSQL has the INTERVAL type, which can be defi= ned with fields such as:

INTERVAL YEAR TO MONTH    (year-mont= h class)
INTERVAL DAY TO SECOND(p)   (day-second c= lass)

It's not possible to define an INTERVAL YEAR TO SECOND(p), which makes sense, since the number of = days in a month can vary. Other SQL engines like Oracle and Informix also h= ave 2 classes of interval types.

However, the ISO-8601 standard format for durations= allows to specify year/month with day to second parts, for example:

P2Y10M15DT10H30M20S

Seems PostgreSQL accepts t= his format in input.
But what does it mean exac= tly?
What is the actual INTERVAL value and INTERVAL class of this?

Testing with V15.1:=

What is the interval class= in this case:

test1=3D> select cast('P2Y10M15DT10H30M20S' as= interval);
             interval   &= nbsp;        
----------------------------------
 2 years 10 mons 15 days = 10:30:20
(1 row)

Should the following convert to a day-second interval?

test1=3D> select cast('P2= Y10M15DT10H30M20S' as interval day to second);
             interval &nb= sp;          
----------------------------------
 2 years 10 mons 15 days 10:30:20
(1 row)

Should PostgreSQL not raise an SQL error= in above cases?


When using invalid INTERVAL f= ields, error is raised as expected:

test1=3D> sel= ect cast('P2Y10M15DT10H30M20S' as interval year to second);
ERROR:  syntax error at or near "se= cond"
LINE 1: ...lect cast('P2Y10M15= DT10H30M20S' as interval year to second);


Does PostgreSQL assume tha= t a month is ~30 days?

I did not find details abo= ut this in the documentation.

Thanks in advance!
Seb

--_000_AM9P191MB1286AD77B5FBAF4640E7274AB0FD9AM9P191MB1286EURP_--