Re: [SQL] date + interval year - why is the return type convered to a timestamp?

2009-10-22 Thread Tom Lane
the6campbells writes: > Why is Postgres returning a timestamp instead of the expected date data type > for the first expression (the second returns a date)? > select date '2001-03-30' - interval '1' year, date '2001-03-30' - integer > '365' from tversion Would you expect a date for date

[SQL] date + interval year - why is the return type convered to a timestamp?

2009-10-22 Thread the6campbells
Why is Postgres returning a timestamp instead of the expected date data type for the first expression (the second returns a date)? In other words, is this a known bug or is it design intent. The manuals did not seem to appear to say this is intentional behaviour but is not SQL standard. select da

Re: [SQL] Date Interval

2005-12-06 Thread Magdalena Komorowska
It works great, very nice method :-) thanks a lot! MK ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Date Interval

2005-12-06 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Bruce Momjian writes: > Magdalena Komorowska wrote: >> Hi, >> I hale a problem with counting interwal and I can't find what to do with >> this. >> I have two fields in the table: >> Column | Type | Modifiers >> -+-+--- >> d

Re: [SQL] Date Interval

2005-12-06 Thread Michael Fuhr
On Tue, Dec 06, 2005 at 11:54:05AM -0500, Bruce Momjian wrote: > test=> SELECT current_timestamp + cast(x || ' months' AS INTERVAL) FROM > test; >?column? > --- > 2006-03-06 11:53:05.574279-05 > (1 row) Or another way: test=> CREATE TABLE test (x numeric);

Re: [SQL] Date Interval

2005-12-06 Thread Bruce Momjian
Magdalena Komorowska wrote: > Hi, > I hale a problem with counting interwal and I can't find what to do with > this. > I have two fields in the table: > Column | Type | Modifiers > -+-+--- > date_in | date| > interwal_months | numeric | >

[SQL] Date Interval

2005-12-06 Thread Magdalena Komorowska
Hi, I hale a problem with counting interwal and I can't find what to do with this. I have two fields in the table: Column | Type | Modifiers -+-+--- date_in | date| interwal_months | numeric | -+-+--- Query

Re: [SQL] Date / interval question

2004-02-20 Thread Gnugeek
I'm looking for a way, within SQL, given a starting date and an ending date, to get back the number of months between the start and end date. If I "SELECT end_date - start_date", I get back an interval in days; I need months. Thanks for any suggestions, Brian ---(end o

Re: [SQL] Date interval

2003-09-25 Thread sad
On Friday 26 September 2003 09:18, you wrote: > I am looking for a way to convert an interval into a number of days ( > integer); > > In sybase I would use : > > days(today()-r_expire) SELECT now()::DATE - '1900-12-10'::DATE; ?column? 375

Re: [SQL] Date interval

2003-09-25 Thread Tomasz Myrta
I am looking for a way to convert an interval into a number of days ( integer); In sybase I would use : days(today()-r_expire) where r_expire is the timestamp I am comparing against. How do we do this in postgres? date_trunc(today()-r_expire) does not seem to do it select extract(epoch f

[SQL] Date interval

2003-09-25 Thread Richard Sydney-Smith
I am looking for a way to convert an interval into a number of days ( integer);   In sybase I would use :   days(today()-r_expire)   where r_expire is the timestamp I am comparing against.   How do we do this in postgres?   date_trunc(today()-r_expire) does not seem to do it   thanks   Richa