Excerpts from Manuel Diego's message of vie oct 29 11:57:20 -0300 2010:
> Buenas,
>     ¿Alguien sabe como funciona el BETWEEN respecto a las columnas  
> TIMESTAMP? Explico mi inquietud:
> 
> Si hago:
> 
> SELECT * FROM table WHERE columna_timestamp BETWEEN '2010-01-01' AND  
> '2010-01-02';
> 
> Me trae todas las filas del 2010-01-01 pero no las del 02.

Es natural.  Puedes ver exactamente qué está haciendo creando una vista
y mirando cómo imprime la definición.  Observa que las fechas se convierten
a timestamp, poniendo las horas en 00:00:00.

alvherre=# create table foo (a timestamp);
CREATE TABLE
alvherre=# create view bar as select * from foo where a between '2010-01-01' 
and '2010-01-02';
CREATE VIEW
alvherre=# \d+ bar
                                 Vista «alvherre.bar»
 Columna │            Tipo             │ Modificadores │ Almacenamiento │ 
Descripción 
─────────┼─────────────────────────────┼───────────────┼────────────────┼─────────────
 a       │ timestamp without time zone │               │ plain          │ 
Definición de vista:
 SELECT foo.a
   FROM foo
  WHERE foo.a >= '2010-01-01 00:00:00'::timestamp without time zone AND foo.a 
<= '2010-01-02 00:00:00'::timestamp without time zone;


-- 
Álvaro Herrera <[email protected]>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
-
Enviado a la lista de correo pgsql-es-ayuda ([email protected])
Para cambiar tu suscripci�n:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responder a