pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nacef LABIDI <nacef.l@gmail.com>
To: Colin Wetherbee <cww@denterprises.org>
Cc: Frank Bax <fbax@sympatico.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: First day of month, last day of month
Date: Thu, 24 Apr 2008 16:43:40 +0200
Message-ID: <f16f7ea00804240743la32b08cm6ced0d9ced56948a@mail.gmail.com> (raw)
In-Reply-To: <481095FB.7090600@denterprises.org>
References: <f16f7ea00804240559y6694c19fx102e57ea4455b07d@mail.gmail.com>
	<481085D1.2010807@sympatico.ca>
	<48108813.6070401@sympatico.ca>
	<481095FB.7090600@denterprises.org>

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@denterprises.org>
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) = 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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

view thread (21+ messages)  latest in thread

Message-ID: <f16f7ea00804240743la32b08cm6ced0d9ced56948a@mail.gmail.com>
Permalink:  ../f16f7ea00804240743la32b08cm6ced0d9ced56948a@mail.gmail.com/
Also on:    postgresql.org/message-id/f16f7ea00804240743la32b08cm6ced0d9ced56948a@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: nacef.l@gmail.com, cww@denterprises.org, fbax@sympatico.ca
  Subject: Re: First day of month, last day of month
  In-Reply-To: <f16f7ea00804240743la32b08cm6ced0d9ced56948a@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox