Re: SQL Time Issue

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: <operationsengineer1(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: SQL Time Issue
Date: 2005-08-31 21:55:10
Message-ID: 11AD3A04-5625-494A-A754-CFB10CFAE680@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Sep 1, 2005, at 4:33 AM, <operationsengineer1(at)yahoo(dot)com> wrote:

> WHERE t_inspect.inspect_timestamp::date >
> (current_date::timestamp - 720 'sec'::interval)

What error did you get? Also, it's always helpful to provide a small,
self-contained test case so others may try exactly what you have done.

Looking at it quickly, I'd say you want '720 sec'::interval or 720 *
'1 sec'::interval. On v8.0.3:

test=# select 720 'sec'::interval;
ERROR: syntax error at or near "'sec'" at character 12
LINE 1: select 720 'sec'::interval;
^
test=# select '720 sec'::interval;
interval
----------
00:12:00
(1 row)

> inspect_timestamp is datatype timestamp. i probably
> shouldn't cast it to date, now that i think about
> it... but i bet that won't make the query run right
> all by itself.

Don't bet :) Try it and see!

> i want to pull all the events that occurred from
> (today - 2 hours) forward (all events during todays
> current date and the last 2 hours from yesterday).

(As an aside, you can see that 720 seconds is not two hours. I think
you mean 7200 seconds.)

Does this help?

Michael Glaesemann
grzm myrealbox com

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-08-31 23:47:35 Re: SQL Time Issue
Previous Message operationsengineer1 2005-08-31 19:33:48 SQL Time Issue