From: tjk@tksoft.com <tjk@tksoft.com>
To: frank@x9media.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] datetime query issue
Date: Sat, 28 Aug 1999 11:23:51 -0700 (PDT)
Message-ID: <199908281823.LAA22218@uno.tksoft.com> (raw)
In-Reply-To: <19990828153506.A18896@shark.x9media.com>
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
>
>
> ************
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tjk@tksoft.com, frank@x9media.com
Subject: Re: [SQL] datetime query issue
In-Reply-To: <199908281823.LAA22218@uno.tksoft.com>
References: <19990828153506.A18896@shark.x9media.com> <199908281823.LAA22218@uno.tksoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox