From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ken Tanzer <ken.tanzer@gmail.com>
To: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Immutable way to cast timestamp TEXT to DATE? (for index)
Date: Fri, 4 Jan 2019 14:27:02 -0800
Message-ID: <85d0c08f-64ea-b980-a6cd-425b97159c8d@aklaver.com> (raw)
In-Reply-To: <CAD3a31XupySutj+RGLxQrOqji5gBZo6Z05rAYgRDRH10wi4Mag@mail.gmail.com>
References: <CAD3a31XupySutj+RGLxQrOqji5gBZo6Z05rAYgRDRH10wi4Mag@mail.gmail.com>
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 <mailto:ken.tanzer@agency-software.org>
> (253) 245-3801
>
> Subscribe to the mailing list
> <mailto:agency-general-request@lists.sourceforge.net?body=subscribe> to
> learn more about AGENCY or
> follow the discussion.
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, ken.tanzer@gmail.com
Subject: Re: Immutable way to cast timestamp TEXT to DATE? (for index)
In-Reply-To: <85d0c08f-64ea-b980-a6cd-425b97159c8d@aklaver.com>
References: <CAD3a31XupySutj+RGLxQrOqji5gBZo6Z05rAYgRDRH10wi4Mag@mail.gmail.com> <85d0c08f-64ea-b980-a6cd-425b97159c8d@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox