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 5 of 15 Topic 3430 of 3717
Post > Topic >>

Re: First day of month, last day of month

by cww@[EMAIL PROTECTED] (Colin Wetherbee) Apr 24, 2008 at 10:15 AM

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) = extract(month 
>> from now()) and extract(year from mydate) = extract(year from now());
> 
> Sorry; I was not thinking clearly - date_trunc is better for this:
> 
> select * from mytable where date_trunc('month',mydate) = 
> date_trunc('month',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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 15 Posts in Topic:
First day of month, last day of month
nacef.l@[EMAIL PROTECTED]  2008-04-24 14:59:47 
Re: First day of month, last day of month
fbax@[EMAIL PROTECTED] (  2008-04-24 09:06:25 
Re: First day of month, last day of month
fbax@[EMAIL PROTECTED] (  2008-04-24 09:16:03 
Re: First day of month, last day of month
andreas.kretschmer@[EMAIL  2008-04-24 15:15:36 
Re: First day of month, last day of month
cww@[EMAIL PROTECTED] (C  2008-04-24 10:15:23 
Re: First day of month, last day of month
erik@[EMAIL PROTECTED] (  2008-04-24 09:41:04 
Re: First day of month, last day of month
nacef.l@[EMAIL PROTECTED]  2008-04-24 16:43:40 
Re: First day of month, last day of month
scott.marlowe@[EMAIL PROT  2008-04-24 08:55:31 
Re: First day of month, last day of month
fhevia@[EMAIL PROTECTED]   2008-04-24 12:10:34 
Re: First day of month, last day of month
scott.marlowe@[EMAIL PROT  2008-04-24 08:56:50 
Re: First day of month, last day of month
erik@[EMAIL PROTECTED] (  2008-04-24 10:08:10 
Re: First day of month, last day of month
scott.marlowe@[EMAIL PROT  2008-04-24 09:16:01 
Re: First day of month, last day of month
scott.marlowe@[EMAIL PROT  2008-04-24 09:44:44 
Re: First day of month, last day of month
fhevia@[EMAIL PROTECTED]   2008-04-24 13:07:19 
Re: First day of month, last day of month
nacef.l@[EMAIL PROTECTED]  2008-04-24 18:39:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Mon Oct 13 4:17:42 CDT 2008.