Re: Querying date_time for date only ? - Mailing list pgsql-sql

From Aarni Ruuhimäki
Subject Re: Querying date_time for date only ?
Date
Msg-id 200512201533.42043.aarni@kymi.com
Whole thread Raw
In response to Re: Querying date_time for date only ?  (Michael Burke <michael@engtech.ca>)
List pgsql-sql
On Tuesday 20 December 2005 15:19, Michael Burke wrote:
> On December 20, 2005 08:59 am, Aarni Ruuhimäki wrote:
> > Hello List,
> >
> > 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.
> >
> > (Pg)SQL way to do this ?
>
> You can try,
>
> SELECT field::date FROM mytable;
>
> to select only the date part.  Likewise, you can use field::time if you
> want to disregard the date.
>

That's neat, thanks.

I was just getting there with

WHERE ... AND EXTRACT('day' FROM res_date_time) = $day
AND EXTRACT('month' FROM res_date_time) = $month
AND ...,

which may be useful elsewhere.

> > TIA,
> >
> > Aarni
>
> HTH.
> Mike.

Merry Christmas to everyone,

Aarni


pgsql-sql by date:

Previous
From: Michael Burke
Date:
Subject: Re: Querying date_time for date only ?
Next
From: Michael Burke
Date:
Subject: Sub-query as function argument