Skip site navigation (1) Skip section navigation (2)

Re: timestamp interval issue

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: "Lonni J Friedman" <netllama(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: timestamp interval issue
Date: 2007-10-05 23:35:01
Message-ID: (view raw or whole thread)
Lists: pgsql-novice
On Oct 5, 2007, at 17:47 , Lonni J Friedman wrote:

> 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.

Would something like this work for you?

select *
from footable0
where case when current_time < '16:00'::time
            then date_created between (current_date - 1) + interval  
'16 hours'
                                and current_date + interval '16 hours'
            else date_created between current_date + interval '16 hours'
                                and (current_date + 1) + interval '16  

I'm not sure if I'm interpreting what you need properly, but I think  
this does what you want.

Michael Glaesemann
grzm seespotcode net

In response to


pgsql-novice by date

Next:From: Michael GlaesemannDate: 2007-10-05 23:37:21
Subject: Re: timestamp interval issue
Previous:From: Lonni J FriedmanDate: 2007-10-05 23:33:01
Subject: Re: timestamp interval issue

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group