Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: First day o...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3434 of 3558
Post > Topic >>

Re: First day of month, last day of month

by Bart.Degryse@[EMAIL PROTECTED] ("Bart Degryse") Apr 24, 2008 at 04:47 PM

--=__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>&gt;&gt;&gt; "Nacef LABIDI"
&lt;nacef.l@[EMAIL PROTECTED]
 2008-04-24 16:43 &gt;&gt;&gt;<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
=
&lt;<A href=3D"mailto:cww@[EMAIL PROTECTED]
">cww@[EMAIL PROTECTED]
>&gt; =
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. &nbsp;Would you mind explaining how =
date_trunc() is better for this?<BR><BR>Most of my extract() results end =
up in &lt;select&gt; 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__=--




 3 Posts in Topic:
Re: First day of month, last day of month
Bart.Degryse@[EMAIL PROTE  2008-04-24 16:47:14 
Re: First day of month, last day of month
terry@[EMAIL PROTECTED]   2008-04-24 10:52:43 
Re: First day of month, last day of month
erik@[EMAIL PROTECTED] (  2008-04-24 10:07:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 4 22:41:29 CDT 2008.