Search Postgresql Archives

Re: Find Number Of Sundays Between Two Dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/5/08, A. Kretschmer <andreas.kretschmer@xxxxxxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux