first of month - Mailing list pgsql-sql

From DHS Webmaster
Subject first of month
Date
Msg-id 3FD72BAC.90CC3C38@dhs-club.com
Whole thread Raw
List pgsql-sql
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!


pgsql-sql by date:

Previous
From: Chris Travers
Date:
Subject: How to completely move a table to another schema?
Next
From: Tom Lane
Date:
Subject: Re: How to specify the beginning of the month in Postgres SQL syntax?