From: Rodrigo De León <rdeleonp@gmail.com>
To: pgsql-sql@postgresql.org, Joshua <joshua@joshuaneil.com>
Subject: Re: current_date / datetime stuff
Date: Mon, 4 Jun 2007 11:25:51 -0500
Message-ID: <a55915760706040925n5c8286f9t7e11989ca22559ab@mail.gmail.com> (raw)
In-Reply-To: <46642A05.40708@joshuaneil.com>
References: <46642A05.40708@joshuaneil.com>
On 6/4/07, Joshua <joshua@joshuaneil.com> wrote:
> Hello,
>
> I was hoping someone here may be able to help me out with this one:
>
> Is there anything similiar to: SELECT current_date;
> that will return the date of the first Monday of the month?
>
> Please let me know.
>
> Thanks,
> Joshua
select (
select
case i <= dow
when true then d + (i - dow + 7)
when false then d + (i - dow)
end
from (
select d
, extract(dow from d)::int as dow
, 1 as i -- monday
from (
select date_trunc('month',current_date)::date - 1 as d
) q
) q2
) as first_monday_of_the_month
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rdeleonp@gmail.com, joshua@joshuaneil.com
Subject: Re: current_date / datetime stuff
In-Reply-To: <a55915760706040925n5c8286f9t7e11989ca22559ab@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox