Received: from as.tksoft.com (gyw.com [209.55.67.177] (may be forged)) by hub.org (8.9.3/8.9.3) with ESMTP id OAA93555 for ; Sat, 28 Aug 1999 14:27:42 -0400 (EDT) (envelope-from tjk@tksoft.com) Received: (from tjk@tksoft.com) by uno.tksoft.com (8.8.8/8.8.8) id LAA22218; Sat, 28 Aug 1999 11:23:51 -0700 From: "tjk@tksoft.com" Message-Id: <199908281823.LAA22218@uno.tksoft.com> Subject: Re: [SQL] datetime query issue To: frank@x9media.com (Frank Joerdens) Date: Sat, 28 Aug 1999 11:23:51 -0700 (PDT) Cc: pgsql-sql@postgreSQL.org In-Reply-To: <19990828153506.A18896@shark.x9media.com> from "Frank Joerdens" at Aug 28, 99 03:35:07 pm Content-Type: text Frank, Use the date_part function to extract the hour and then find the records which match. E.g. select id,date_part('hour', mydate) from table1 where date_part('hour', mydate) >= 6 and date_part('hour', mydate) <= 22; Troy > > I'm not sure how to go about this: I want to find all rows with a timestamp > between, say 6 a.m. and 10 p.m. for any number of days. The column format is > datetime. How do I extract the 'time of the day' information from this > column? What I can think of is to create a view for every single day where datetime > is > 6 and < 10 and then another query on all views together but that doesn't sound > very elegant and would be a real memory hog for a large number of days. > > Any better ideas? > > Thanks > > Frank > > > ************ > >