Re: timestamp interval issue

From: Nis Jørgensen <nis(at)superlativ(dot)dk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: timestamp interval issue
Date: 2007-10-08 11:14:59
Message-ID: fed3fo$r3m$1@sea.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Nis Jørgensen skrev:
> Lonni J Friedman skrev:
>> Greetings,
>> I've got an interesting problem. I have a table with a column full of
>> timestamps. I need a means of returning only the rows which have a
>> timestamp that falls after the last 16:00 and before the next 16:00
>> (on the clock), regardless of date.

> SELECT *
> FROM footable0
> WHERE (date_created - interval '16 hours')::date = (now() - interval '16
> hours')::date;
>
> Tested.

Unfortunately, the performance is horrible - it is using a seqscan. Use
Michaels suggestion instead (at least if you have a significant amount
of data).

Nis

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Glaesemann 2007-10-08 13:37:19 Re: timestamp interval issue
Previous Message Nis Jørgensen 2007-10-08 10:46:06 Re: timestamp interval issue