From: | Aleksey Dashevsky <postgres(at)luckynet(dot)co(dot)il> |
---|---|
To: | BD Postgres <postgres(at)master(dot)abrente(dot)es> |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] sql date functions |
Date: | 1998-07-06 11:26:22 |
Message-ID: | Pine.LNX.3.96.SK.980706141824.9426A-100000@kesha.luckynet.co.il |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, 6 Jul 1998, BD Postgres wrote:
> Aleksey Dashevsky wrote:
>
> > I think you need to rewrite this query with something like:
> >
> > insert into table1 (date1,date2) values('1997-2-3'::date,'1997-2-3'::date
> > + '1 week'::timespan);
> >
> > You can also use standard SQL-92 syntax for type casting, e.x.:
> > cast ('1 week' as timespan )
> > etc.
>
>
> You are right, but now postgres is reporting me that there is no '+' operator
> defined for time and timespan, but I have found that I can add integers to
> dates and they are threaded as days so I can solve my problem easily.
>
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 );
From | Date | Subject | |
---|---|---|---|
Next Message | Barracuda | 1998-07-06 12:09:46 | Thanks |
Previous Message | BD Postgres | 1998-07-06 11:09:22 | Re: [SQL] sql date functions |