| From: | DHS Webmaster <webmaster(at)dhs-club(dot)com> |
|---|---|
| To: | jeff(at)dnuk(dot)com, pgsql-sql(at)postgresql(dot)org |
| Subject: | first of month |
| Date: | 2003-12-10 14:20:28 |
| Message-ID: | 3FD72BAC.90CC3C38@dhs-club.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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!
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2003-12-10 15:51:48 | Re: How to specify the beginning of the month in Postgres SQL syntax? |
| Previous Message | Chris Travers | 2003-12-10 12:21:08 | How to completely move a table to another schema? |