[SQL] Re: dates in functions

2001-03-02 Thread Salvador Mainé
The correct function is: CREATE function anyo_hidro (date) returns int AS ' BEGIN RETURN date_part(''month'',$1); END; ' LANGUAGE 'plpgsql'; By the way: Do you know what 'RTFM' means? Salvador Mainé escribió: > >

[SQL] dates in functions

2001-03-02 Thread Salvador Mainé
Hello: I'm trying to define a function that, given a date, returns its month. The definition is as follows: CREATE function anyo_hidro (date) returns int AS ' BEGIN RETURN date_part("month",$1); END; ' LANGUAGE 'plpgsql'; But when I do: select anyo_hidro('1-1-1999'); I g

[SQL] SQL problem

2001-03-12 Thread Salvador Mainé
Hello: I have a table with pluviometrical data meteo (rain float, day date) I want to select the the day of maximum value for each year.It should be something like : select max(rain),day from meteo group by date_part('year', day); but it obiously doesn't work. I thought of doing it with agg

[SQL] I need an aggregate with 2 parameters

2001-03-12 Thread Salvador Mainé
Hello: I have a table with pluviometrical data meteo (rain float, day date, oid station) I want to select the the day of maximum value for each year for a given measurement station. It should look like : select max(rain),day from meteo group by date_part('year', day) where station=7654765; th

[SQL] date_part bug?

2001-03-29 Thread Salvador Mainé
Hello: I'm using postgres 7.0.2. When I use date_part('day', date) sometimes I get wrong values. Ie: and date_part('day', '1999-3-28')=27 and date_part('day', '2000-3-26')=25 Is it a bug? Is there any SQL equivalent function? -- Salva