| From: | "Dawid Kuroczko" <qnex42(at)gmail(dot)com> |
|---|---|
| To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Find Number Of Sundays Between Two Dates |
| Date: | 2008-03-05 12:30:52 |
| Message-ID: | 758d5e7f0803050430n32fb5132q89aee5d832358bee@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 3/5/08, A. Kretschmer <andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> With generate_series() i generate a list of dates, and later i check if
> the date are a saturday. Okay, you need to know sunday -> change from 6
> to 0 and ou course, you can calculate the parameter for the
> generate_series like
I find it convenient to create a custom version of generate_series:
CREATE OR REPLACE FUNCTION generate_series(date,date)
RETURNS SETOF date AS $$
SELECT $1 + n FROM generate_series(0,$2-$1) AS x(n)
$$ LANGUAGE SQL IMMUTABLE;
Regards,
Dawid
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Professor Flávio Brito | 2008-03-05 13:10:27 | Re: Documenting a DB schema |
| Previous Message | Conor McTernan | 2008-03-05 11:06:28 | JOIN and difference between timestamps |