From: Francis Solomon <francis@stellison.co.uk>
To: Jeff MacDonald <jeff@hub.org>
To: Pgsql-Sql@Postgresql. Org <pgsql-sql@postgresql.org>
Subject: RE: substring ..
Date: Tue, 19 Dec 2000 20:14:00 -0000
Message-ID: <NEBBIFFPELJMCJAODNPKMECECEAA.francis@stellison.co.uk> (raw)
In-Reply-To: <Pine.BSF.4.21.0012191505370.3386-100000@rage.hub.org>
Hi Jeff,
'2000-12-14' is only 10 chars long.
You're asking for an 11-char long substring to match a 10-char ... not
going to happen!
You can see this better if you do something like this ...
select '@' || substr(datefoo,1,11) || '@' from table;
... and you'll get results like:
@2000-12-14 @
So, you could modify your query to do:
select foo from table where substr(datefoo, 1, 10) = '2000-12-14';
Alternatively, what's wrong with this approach?
select foo from table where date(datefoo) = '2000-12-14';
I think that might execute a little faster.
Hope this helps
Francis Solomon
> hi folks..
>
> i want to do this to a datetime field..
>
> select foo from table where substr(datefoo,1,11) = '2000-12-14';
>
> it returns no results yet..
>
> select substr(datefoo,1,11) does return some values that say
> 2000-12-14
>
> any clues ?
>
> Jeff MacDonald,
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: francis@stellison.co.uk, jeff@hub.org
Subject: RE: substring ..
In-Reply-To: <NEBBIFFPELJMCJAODNPKMECECEAA.francis@stellison.co.uk>
* 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