From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: date ranges in where |
Date: | 2009-05-07 11:59:38 |
Message-ID: | gtuifa$urb$3@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2009-05-06, Miguel Miranda <miguel(dot)mirandag(at)gmail(dot)com> wrote:
> --00032557620e737136046944dbf1
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 7bit
>
> Hi, what is the recommended way to select a range of dates?
if you want to compare dates, use dates!
> Lets say a have a table with a lastlogin (timestamp) column and i want
> toknow what users logged in for last time between 2009-05-01 and 2009-05-02?
>
> I know that a simple
>
> where lastlogin between '2009-05-01' and '2009-05-02' doesnt work beacuse it
> doesnt include who logged in 2009-05-02 15:30:00, etc...
If you are comparing dates it does.
where lastlogin::date between '2009-05-01'::date and '2009-05-02'::date
If you leave it uncast postgres will probably convert the lastlogin to
a string and produce results other than that desired and proabaly
take longer to do it too.
From | Date | Subject | |
---|---|---|---|
Next Message | Raymond O'Donnell | 2009-05-07 12:12:50 | Re: date ranges in where |
Previous Message | Markus Wollny | 2009-05-07 11:37:00 | Question about function returning record |