Re: [SQL] sql date functions

From: BD Postgres <postgres(at)master(dot)abrente(dot)es>
To: Aleksey Dashevsky <postgres(at)luckynet(dot)co(dot)il>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] sql date functions
Date: 1998-07-06 14:28:41
Message-ID: 35A0DF19.ADFF0E2A@master.abrente.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Aleksey Dashevsky wrote:

> Sorry, I really forgot: if you want to use date interval you need datetime
> type instead of date. Unforunately, postgres can only add timespan to
> datetime, but not to date, and also it doesn't have autoconversion from
> date to datetime:-(
>
> So, you eihter need to change all mentions of date type with datetime
> (don't forget to change it also in "create table"), or you need to cast
> back datetime to date:
>
> insert into table1 (date1,date2) values('1997-2-3'::date,('1997-2-3'::datetime
> + '1 week'::timespan)::date );

I'm using now dates and integers and it seems to work from psql although it's
giving me some problems from perl.

insert into quinielas (id,temporada,jornada,inicio,final) values
(13,1,1,'1-2-3'::date,'1-2-3'::date + 3);
works from psql ok, but when I try to do it from perl with DBI with

$sth->prepare('... values (?,?,?,?::date+?,?::date+?)');
$sth->execute(13,1,1,'1-2-3',3,'1-2-3',5);

it fails with a 'parameter unknown' error to the perl side although the postmaster
do not report any error. It seems to me this is more from perl that from postgres,
but anyway, some idea ?

- Salva.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Chairudin Sentosa Harjo 1998-07-08 09:10:41 Date
Previous Message Brett W. McCoy 1998-07-06 13:59:03 Re: [SQL] How to split very long tables?