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 1jiQRH-0002En-CZ for pgsql-general@arkaria.postgresql.org; Mon, 08 Jun 2020 22:40:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jiQRG-0001Wj-9Q for pgsql-general@arkaria.postgresql.org; Mon, 08 Jun 2020 22:40:18 +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 1jiQRG-0001Wc-1X for pgsql-general@lists.postgresql.org; Mon, 08 Jun 2020 22:40:18 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiQR7-0003ql-IS for pgsql-general@postgresql.org; Mon, 08 Jun 2020 22:40:17 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E5E4C5C00EC; Mon, 8 Jun 2020 18:40:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 08 Jun 2020 18:40:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=q hkQX9Dyi8+h/H7rdsbO2FPH2EZrLJa1HU/QYpQxE9E=; b=HKQH2a0mg/qE2TJ8P u26yrHH6VqP11f9aBwCi6PcRrnKiBSXYKi3SuRFtS5aUZtRxixC0x5vEHnZF+qJf ywhKwd/VjDt+C+Yl7KNaGPnFQjrfHyJ3Ew6TczgrKNir+9Q7HZbtd6MU0GS1WGgb XyBZDcNIMcXKKUb91h8EdGOdc4cRl882iPXimHceg2JhFF8L82bmUhW7TDzuBVdX C1GADSUCxFyKG8z8hZhzHqb1pyRpPQab5Pxp9qonK4bL8sRW1y0xUoUIXp2zLYS/ 4qwbVz0uGuDXvTq4mDMn7t65k4jOmIZngTE4oCYZ9ls/lCBbvc99xVhJLXNacCHE 4oXlQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=qhkQX9Dyi8+h/H7rdsbO2FPH2EZrLJa1HU/QYpQxE 9E=; b=KbLnA8OXjnlXy/ORmzBLCh7KDW5AuEl7n55pgZQWj+cOA6tM2UYrnl9kA agfRZ0ucC8F+9XHMzMaYxjshI6TJC8U/sZW8JV1KEU740F/8QeJBV4Mbh+rzo+iQ QjZZGjpOCvsyYXFViBI1bMaYRKLhmI9H10Me0XxgRWk1GKzZzTWX3tRNFsFBT/6P D0+nKkXJ/7+kVnXmT8tGNXkpjj4jEHSMBONk9geNqgLmYtToL9/y9W6mzO9elXDX +h4JRfWtaC3eN7K5Hv+vxt93KXKeLKbUVRZ+RcBZ5c1GGhSSMOlQ3LTUonW/99se 9n+Y1uD+wFGD4+fdGiz9vB9oML+vA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudehfedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeetjedvteffjeeuvdelieeffeehuedthffgvdfhhffh kedvudevgedvjedufefgveenucfkphepjeehrddujedvrdehrddvfedunecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgr vhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id E0C393060F09; Mon, 8 Jun 2020 18:40:05 -0400 (EDT) Subject: Re: Is it possible to use keywords (date units) in a function definition? To: "David G. Johnston" , Alistair Johnson Cc: pgsql-general References: From: Adrian Klaver Message-ID: Date: Mon, 8 Jun 2020 15:40:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/8/20 3:10 PM, David G. Johnston wrote: > On Mon, Jun 8, 2020 at 2:57 PM Alistair Johnson > wrote: > > > RETURN EXTRACT(datepart FROM end - start); > Any ideas? Is this even possible? > > > Use the "date_part" function. That would work on the Postgres side, but the OP also wants this to run on BigQuery and unfortunately it won't work there. > > David J. -- Adrian Klaver adrian.klaver@aklaver.com