Re: First day of month, last day of month
От | Bart Degryse |
---|---|
Тема | Re: First day of month, last day of month |
Дата | |
Msg-id | 4810B991.A3DD.0030.0@indicator.be обсуждение исходный текст |
Ответ на | Re: First day of month, last day of month ("Nacef LABIDI" <nacef.l@gmail.com>) |
Ответы |
Re: First day of month, last day of month
|
Список | pgsql-sql |
Well, that's what it does afaikt.<br /><br />>>> "Nacef LABIDI" <nacef.l@gmail.com> 2008-04-24 16:43 >>><br/>Actually I want to select all rows whith dates between first day of the month 00:00:00 and last date ofthe 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="PADDING-LEFT:1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Frank Bax wrote:<br /><blockquoteclass="gmail_quote" style="PADDING-LEFT: 1ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Frank Bax wrote:<br /><blockquoteclass="gmail_quote" style="PADDING-LEFT: 1ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><div class="Ih2E3d">NacefLABIDI wrote:<br /><blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; BORDER-LEFT: rgb(204,204,204)1px solid">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 по дате отправления: