Skip site navigation (1) Skip section navigation (2)

Re: substring ..

From: "Joel Burton" <jburton(at)scw(dot)org>
To: Jeff MacDonald <jeff(at)hub(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: substring ..
Date: 2000-12-19 20:08:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
> 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

Ummm... because '2000-12-14' is a ten-character, not eleven 
character long string. Try substr(datefoo,1,10) and it works for me 
(under 7.1devel).

However, this all seems sloppy. Why not extract the date, and 
compare it as a date?

Joel Burton, Director of Information Systems -*- jburton(at)scw(dot)org
Support Center of Washington (

In response to

pgsql-sql by date

Next:From: Tulio OliveiraDate: 2000-12-19 20:13:09
Subject: Re: substring ..
Previous:From: Stephan SzaboDate: 2000-12-19 20:07:33
Subject: Re: substring ..

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group