Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfXvu-0004vm-83 for pgsql-general@arkaria.postgresql.org; Fri, 04 Jan 2019 22:27:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfXvt-0004s7-04 for pgsql-general@arkaria.postgresql.org; Fri, 04 Jan 2019 22:27:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfXvr-0004rz-LU for pgsql-general@lists.postgresql.org; Fri, 04 Jan 2019 22:27:12 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfXvn-0001oq-GI for pgsql-general@postgresql.org; Fri, 04 Jan 2019 22:27:11 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id DE01114C4; Fri, 4 Jan 2019 17:27:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 04 Jan 2019 17:27:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=N NtVKg5aqulN58ndILTTc8UB60l/YZ3KFJzf9PjECU8=; b=0rQbMdiP4oIlePO42 wBAs6ovtyAxBiANP0SMktcPjh5gd0ZaHDilVzyBYo58SExUF/GRWw9+riQn/8A8s 1lR5vFOYfQ7LOS66WWFV+TaRbSfk7lbFYWcU56HuDVVqY5Wd1ZLeEJA0fT5pC9LI mGcyhk8Wt7bOYn8VtdNe9b6bVTX8u1o8KNOOBOyv5wGIKjQSjfUyvOcwjiX6rf1H 12aPyzmdd6yhSl8x+q1a612tbKxroKukv7dOrHBZ1pvi5swAUv6rznQR0B9B77uq qc/Ef8YAmJo6TAAOBQOuVh9OtjofBZ2W5QAcikfvOf6JR41hIpFnuLfqEujcJHnq JjaXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm1; bh=NNtVKg5aqulN58ndILTTc8UB60l/YZ3KFJzf9PjEC U8=; b=j59xgdAgU56r+PVT5pZnuiQ+UquDzN88ICvnkjQIS03HmZQPu5jDEDvbm g/zMy6841YfnlElCivgRktG9PvVKk7JGc76grbg8MhkkKIRteAlCXgbGrn+TTJYy mWmMh0pi5H4u3DcLB7JGbeI3Gf0qdjOdhIjNdZLus3ML5cqtDrjLZjHKcWyhIUpm 9KVZ6dFmYOHDFpNq8lOQInveI3Xw5c6MOb4ckJOmuZEeXIm3D6VCNV4ore7U3103 zvJDqiokEygWAJtZHH9wNUxSbDQ2SOIq/qeUSG9dn29RnfuI62BDrY9fe1bqPzbZ Sv5XeSmnpj7NjDAeXaA8RR7aeWz/A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrvddugdduieefucdltddurdegtdekrddttd dmucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhht necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuffhomhgrihhnpegrghgvnhgthidqshhofhhtfigrrhgvrdhorhhgnecukfhp peejuddrvdduvddrudefgedrfeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirg hnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id B4EC11026D; Fri, 4 Jan 2019 17:27:03 -0500 (EST) Subject: Re: Immutable way to cast timestamp TEXT to DATE? (for index) To: Ken Tanzer , PG-General Mailing List References: From: Adrian Klaver Message-ID: <85d0c08f-64ea-b980-a6cd-425b97159c8d@aklaver.com> Date: Fri, 4 Jan 2019 14:27:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/4/19 2:21 PM, Ken Tanzer wrote: > Hi.  I've got a text field in a table that holds this style of timestamp: > > 2014-10-23T00:00:00 > > I'd like to be able to create an index on the date portion of this field > (as a date), because I have lots of queries that are searching for > particular dates or ranges. > > I've tried various ways of getting to a date (::date, LEFT(x,10)::date, > etc.), but all of them throw the error "functions in index expression > must be marked IMMUTABLE." ?: '2014-10-23T00:00:00'::timestamp Can you also show the actual index expression? > > Is there any way, hacky or otherwise, people know of to do this?  Thanks > in advance. > > Ken > > > -- > AGENCY Software > A Free Software data system > By and for non-profits > /http://agency-software.org// > /https://demo.agency-software.org/client/ > ken.tanzer@agency-software.org > (253) 245-3801 > > Subscribe to the mailing list >  to > learn more about AGENCY or > follow the discussion. -- Adrian Klaver adrian.klaver@aklaver.com