Re: First day of month, last day of month - Mailing list pgsql-sql

From Nacef LABIDI
Subject Re: First day of month, last day of month
Date
Msg-id f16f7ea00804240743la32b08cm6ced0d9ced56948a@mail.gmail.com
Whole thread Raw
In response to Re: First day of month, last day of month  (Colin Wetherbee <cww@denterprises.org>)
Responses Re: First day of month, last day of month  ("Bart Degryse" <Bart.Degryse@indicator.be>)
Re: First day of month, last day of month  ("Scott Marlowe" <scott.marlowe@gmail.com>)
List pgsql-sql
Actually I want to select all rows whith dates between first day of the month 00:00:00 and last date of the month
23:59:59<br/><br /><div class="gmail_quote">On Thu, Apr 24, 2008 at 4:15 PM, Colin Wetherbee <<a
href="mailto:cww@denterprises.org">cww@denterprises.org</a>>wrote:<br /><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Frank Bax wrote:<br
/><blockquoteclass="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> Frank Bax
wrote:<br/><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div
class="Ih2E3d">Nacef LABIDI wrote:<br /><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204,
204);padding-left: 1ex;"> is there a better method to retrieve all the rows with dates in the current month.<br
/></blockquote><br/></div> select * from mytable where extract(month from mydate) = extract(month from now()) and
extract(yearfrom mydate) = extract(year from now());<br /></blockquote><br /> Sorry; I was not thinking clearly -
date_truncis better for this:<br /><br /> select * from mytable where date_trunc('month',mydate) =
date_trunc('month',now());<br/></blockquote><br /> I have some code that uses extract() for this sort of thing.  Would
youmind explaining how date_trunc() is better for this?<br /><br /> Most of my extract() results end up in
<select>drop-down boxes in HTML.<br /><br /> Thanks.<br /><br /> Colin<br /><font color="#888888"><br /><br /> --
<br/> Sent via pgsql-sql mailing list (<a href="mailto:pgsql-sql@postgresql.org"
target="_blank">pgsql-sql@postgresql.org</a>)<br/> To make changes to your subscription:<br /><a
href="http://www.postgresql.org/mailpref/pgsql-sql"target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br
/></font></blockquote></div><br/> 

pgsql-sql by date:

Previous
From: "Bart Degryse"
Date:
Subject: Re: First day of month, last day of month
Next
From: "Bart Degryse"
Date:
Subject: Re: First day of month, last day of month