Search Postgresql Archives

Re: Query to return every 1st Sat of a month between two dates

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

 



2011/5/11 Alex - <aintokyo@xxxxxxxxxxx>:
> Hi,
> is there an easy way to return the date of every first Saturday of a month
> in a data range i.e. 2011-2013
> Any help would be appreciated
> Thanks
> Alex


Try:
SELECT s.a::date+(6-(extract(dow from s.a)::int%7)) FROM
generate_series(to_date('2011','YYYY'),to_date('2012','YYYY'), '1
month') AS s(a);

Osvaldo

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[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