Re: Querying date_time for date only ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Burke <michael(at)engtech(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org, aarni(at)kymi(dot)com
Subject: Re: Querying date_time for date only ?
Date: 2005-12-20 15:05:37
Message-ID: 29114.1135091137@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Michael Burke <michael(at)engtech(dot)ca> writes:
> On December 20, 2005 08:59 am, Aarni Ruuhimki wrote:
>> I have a time stamp without time zone field, YYYY-MM-DD hh:mm:ss, in my
>> table. I want to also find something just for a particular day regardless
>> of the time.

> You can try,
> SELECT field::date FROM mytable;

The date_trunc() function can also be useful for this sort of thing,
particularly if you need to round off to something finer or coarser
than days.
http://www.postgresql.org/docs/8.1/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-12-20 15:07:39 Re: Sub-query as function argument
Previous Message Michael Burke 2005-12-20 15:04:26 Re: Sub-query as function argument