Re: SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps - Mailing list pgsql-sql

From Jasen Betts
Subject Re: SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps
Date
Msg-id gqa9oi$kv1$4@reversiblemaps.ath.cx
Whole thread Raw
In response to SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps  (Srikanth <rssrik@yahoo.co.in>)
List pgsql-sql
On 2009-03-17, Srikanth <rssrik@yahoo.co.in> wrote:

> Dear all,
>
> I have a table that records User Login Sessions with two timestamp fields. =
> Basically Start of Session and End of a Session (start_ts and end_ts). Each=
>  row in the table identifies a session which a customer has used.=A0=20
>
>
> I have to find out how many User Sessions that were present in any given "1=
>  HOUR TIME PERIOD".=A0 A single User Session can span across many days.

select count(*) from session WHERE start_ts < TIME + '1 hour'::intervalAND   end_ts >= TIME;
(replace both ocurrences of TIME with the time the interval starts)


pgsql-sql by date:

Previous
From: Jasen Betts
Date:
Subject: Re: cast bool/int
Next
From: Tom Lane
Date:
Subject: Re: Alter Table/Indexing