On 2009-05-06, Miguel Miranda <miguel.mirandag@xxxxxxxxx> 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. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general