pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: DHS Webmaster <webmaster@dhs-club.com>
To: jeff@dnuk.com
To: pgsql-sql@postgresql.org
Subject: first of month
Date: Wed, 10 Dec 2003 09:20:28 -0500
Message-ID: <3FD72BAC.90CC3C38@dhs-club.com> (raw)

Jeff,
We use a simple function that can be called in any query, like so:
SELECT * FROM table WHERE column < first_of_month();

-- Function: public.first_of_month()
CREATE FUNCTION public.first_of_month() RETURNS date AS '
DECLARE stamp DATE;

BEGIN
SELECT INTO stamp CAST(date_trunc(''month'',now())AS DATE);
return stamp;
END;'  LANGUAGE 'plpgsql' STABLE;

-- 
Bill MacArthur
Webmaster
The DHS Club, Inc.
The Best Is Yet To Come!



Message-ID: <3FD72BAC.90CC3C38@dhs-club.com>
Permalink:  ../3FD72BAC.90CC3C38@dhs-club.com/
Also on:    postgresql.org/message-id/3FD72BAC.90CC3C38@dhs-club.com

 · 

reply

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: webmaster@dhs-club.com, jeff@dnuk.com
  Subject: Re: first of month
  In-Reply-To: <3FD72BAC.90CC3C38@dhs-club.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