Re: TIME ZONE SQL

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Raman Garg" <ramang(at)smartdatainc(dot)com>, "pgsql-sql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: TIME ZONE SQL
Date: 2004-02-05 16:31:06
Message-ID: 200402051631.06274.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thursday 05 February 2004 14:59, Raman Garg wrote:
> Hi Richard,
>
> What I am having is
>
> CREATE TABLE "customer_events" (
> "event_id" numeric (10) NOT NULL,
> "customer_id" numeric (10) NOT NULL,
> "event_name" varchar (100) ,
> "event_datetime" date ,
> "start_time" time ,
> "repeat_untill_date" date ,
> "send_before_time" time,
> "time_difference" time
> PRIMARY KEY ("event_id"))
>
> So my "send_before_time" is of datatype "time" only as you have assumed.
> only difference was, In your table you are having time_difference field as
> "interval" type.
>
> I am subtracting time field from a time field. i.e. start_time::time -
> send_before_time::time
> so creating (start_time::time - send_before_time::time) as start_pt is not
> making any difference at my side.
> (I hope I am getting your point what you have explained)

My point is that subtracting one time from another does not give you a time.
3:30pm (time) - 2:00pm (time) = 1h30m (interval)

If "send_before_time" is an interval (e.g. '1 hour and 30 minutes') you should
probably make it an interval.
If it is in fact a time (e.g. '2:00 pm') then it doesn't make sense to
subtract it.

Even if your solution works, I'd recommend getting your types right - it'll
save effort later.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-02-05 16:54:15 Re: TIME ZONE SQL
Previous Message Raman Garg 2004-02-05 14:59:57 Re: TIME ZONE SQL