Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Adrian Klaver
On 01/19/2012 09:17 AM, Samuel Gendler wrote: On Thu, Jan 19, 2012 at 8:20 AM, Adrian Klaver mailto:adrian.kla...@gmail.com>> wrote: On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote: > The following code works in 8.4 but not 8.3. > Anyone know why, or what I need to

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Samuel Gendler
On Thu, Jan 19, 2012 at 8:20 AM, Adrian Klaver wrote: > On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote: > > The following code works in 8.4 but not 8.3. > > Anyone know why, or what I need to do to change it? > > > > SELECT aid, asid, > >date_range (asdate, afdate)::date AS

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Steve Crawford
On 01/19/2012 07:16 AM, Gary Stainburn wrote: On Thursday 19 January 2012 15:11:46 Gary Stainburn wrote: I'll be upgrading my live server as soon as possible, but in the meantime can anyone suggest a way I can do the same thing using Postgresql 8.1 until I can evaluate 8.4 on my live systems? I

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Adrian Klaver
On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote: > The following code works in 8.4 but not 8.3. > Anyone know why, or what I need to do to change it? > > SELECT aid, asid, >date_range (asdate, afdate)::date AS asdate, >acomments > FROM availability > > In 8.4 it retu

Re: [SQL] SOLVED - date range to set of dates expansion

2012-01-19 Thread Gary Stainburn
Sorry for using the list as a scratch-pad for my brain. select aid, asid, generate_series(asdate-'1970-01-01'::date, afdate-'1970-01-01'::date)+'1970-01-01'::date as adate, acomments from availability; Has done the trick. -- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringw

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Gary Stainburn
The following code works in 8.4 but not 8.3. Anyone know why, or what I need to do to change it? SELECT aid, asid, date_range (asdate, afdate)::date AS asdate, acomments FROM availability In 8.4 it returns the expanded dataset as required. In 8.3 I get: ERROR: set-valued function

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Gary Stainburn
On Thursday 19 January 2012 15:11:46 Gary Stainburn wrote: > I'll be upgrading my live server as soon as possible, but in the meantime > can anyone suggest a way I can do the same thing using Postgresql 8.1 > until I can evaluate 8.4 on my live systems? Sorry, I meant 8.3 as my current version

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Gary Stainburn
On Thursday 19 January 2012 08:32:27 hari.fu...@gmail.com wrote: > > Why don't you just use the built-in PostgreSQL function for that? > > SELECT aid, asid, >generate_series (asdate, afdate, INTERVAL '1 day')::date AS asdate, >acomments > FROM tbl 1) because I didn't know about it

Re: [SQL] how to return whole table from Function not just the id integer column

2012-01-19 Thread Samuel Gendler
On Thu, Jan 19, 2012 at 1:57 AM, Rehan Saleem wrote: > hi , > > how can i return the whole user table from this function not just the id . > thanks > > Chapter 39, specifically 39.3, of the postgresql documentation provides all of the information necessary to answer this question. If, after rea

[SQL] how to return whole table from Function not just the id integer column

2012-01-19 Thread Rehan Saleem
hi , how can i return the whole user table from this function not just the id . thanks CREATE TABLE users(id serial PRIMARY KEY, first_name varchar(10), last_name varchar(10)); CREATE OR REPLACE FUNCTION new_user(fname varchar, lname varchar) RETURNS int AS $$ DECLARE r int; BEGIN -- custom except

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread hari . fuchs
Gary Stainburn writes: > Hi, > > How can I expand a date range in a table to a set of date records? > > I have a table of availabilities thus: > > Column |Type | Modifiers > ---+-+-