--=__PartCFE69A62.2__=
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
Well, that's what it does afaikt.
>>> "Nacef LABIDI" <nacef.l@[EMAIL PROTECTED]
> 2008-04-24 16:43 >>>
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
On Thu, Apr 24, 2008 at 4:15 PM, Colin Wetherbee <cww@[EMAIL PROTECTED]
> =
wrote:
Frank Bax wrote:
Frank Bax wrote:
Nacef LABIDI wrote:
is there a better method to retrieve all the rows with dates in the =
current month.
select * from mytable where extract(month from mydate) =3D extract(month =
from now()) and extract(year from mydate) =3D extract(year from now());
Sorry; I was not thinking clearly - date_trunc is better for this:
select * from mytable where date_trunc('month',mydate) =3D
date_trunc('mont=
h',now());
I have some code that uses extract() for this sort of thing. Would you =
mind explaining how date_trunc() is better for this?
Most of my extract() results end up in <select> drop-down boxes in HTML.
Thanks.
Colin
--=20
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql=20
--=__PartCFE69A62.2__=
Content-Type: text/html; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<META content=3D"MSHTML 6.00.2800.1264" name=3DGENERATOR></HEAD>
<BODY style=3D"MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">Well, that's what =
it does afaikt.<BR><BR>>>> "Nacef LABIDI"
<nacef.l@[EMAIL PROTECTED]
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 of the =
month 23:59:59<BR><BR>
<DIV class=3Dgmail_quote>On Thu, Apr 24, 2008 at 4:15 PM, Colin Wetherbee
=
<<A href=3D"mailto:cww@[EMAIL PROTECTED]
">cww@[EMAIL PROTECTED]
>> =
wrote:<BR>
<BLOCKQUOTE class=3Dgmail_quote style=3D"PADDING-LEFT: 1ex; MARGIN: 0pt =
0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Frank Bax =
wrote:<BR>
<BLOCKQUOTE class=3Dgmail_quote style=3D"PADDING-LEFT: 1ex; BORDER-LEFT: =
rgb(204,204,204) 1px solid">Frank Bax wrote:<BR>
<BLOCKQUOTE class=3Dgmail_quote style=3D"PADDING-LEFT: 1ex; BORDER-LEFT: =
rgb(204,204,204) 1px solid">
<DIV class=3DIh2E3d>Nacef LABIDI wrote:<BR>
<BLOCKQUOTE class=3Dgmail_quote style=3D"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) =3D extract(month from =
now()) and extract(year from mydate) =3D extract(year from
now());<BR></BLO=
CKQUOTE><BR>Sorry; I was not thinking clearly - date_trunc is better for =
this:<BR><BR>select * from mytable where date_trunc('month',mydate) =3D =
date_trunc('month',now());<BR></BLOCKQUOTE><BR>I have some code that uses
=
extract() for this sort of thing. Would you mind 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<B=
R><FONT color=3D#888888><BR><BR>-- <BR>Sent via pgsql-sql mailing list (<A
=
href=3D"mailto:pgsql-sql@[EMAIL PROTECTED]
"
target=3D_blank>pgsql-sql@[EMAIL PROTECTED]
>)<BR>To make changes to your subscription:<BR><A
href=3D"http://w=
ww.postgresql.org/mailpref/pgsql-sql"
target=3D_blank>http://www.postgresql=
..org/mailpref/pgsql-sql</A><BR></FONT></BLOCKQUOTE></DIV><BR></BODY></HTML>
--=__PartCFE69A62.2__=--


|