Re: date range query help

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: "'novice'" <user(dot)postgresql(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: date range query help
Date: 2008-11-20 02:42:51
Message-ID: 045201c94ab9$aef53340$0cdf99c0$@r@sbcglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

> Now user Ben has passed his mobile to user Josh and we issued Josh his
> mobile on 2008-10-15.
>
> 1. Is it possible for me to write a query that will have the fields
>
> call.call_id,
> call.datetime,
> mobile_custodian.user_id,
> call.mobile_no
> call.charge
>
> that will use call.datetime and lookup the date range from
> mobile_custodian.issue_date and mobile_custodian.return_date to
> identify the right user for each call?
>
> 2. Do I need to change the issue_date & return_date fields to
> timestamp to perform the above?
>

No, a date will work fine. Try this:

select call.call_id,
call.datetime,
mobile_custodian.user_id,
call.mobile_no
call.charge
from call, mobile_custodian
where call.mobile_no = mobile_custodian.mobile_no
and call.datetime between mobile_custodian.issue_date
and mobile_custodian.return_date

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message novice 2008-11-20 03:03:05 Re: date range query help
Previous Message novice 2008-11-20 02:10:41 date range query help

Browse pgsql-novice by date

  From Date Subject
Next Message novice 2008-11-20 03:03:05 Re: date range query help
Previous Message novice 2008-11-20 02:10:41 date range query help

Browse pgsql-sql by date

  From Date Subject
Next Message novice 2008-11-20 03:03:05 Re: date range query help
Previous Message novice 2008-11-20 02:10:41 date range query help