Assigning a timestamp without timezone to a timestamp with timezone - Mailing list pgsql-sql

From chrisj
Subject Assigning a timestamp without timezone to a timestamp with timezone
Date
Msg-id 6613652.post@talk.nabble.com
Whole thread Raw
Responses Re: Assigning a timestamp without timezone to a timestamp with timezone  (Andrew Sullivan <ajs@crankycanuck.ca>)
List pgsql-sql
Hi
Does any one have any ideas for the following problem?

Two tables both the have open and close columns that are timestamp or
timestamp with time zone.

One row in first table represents the corporate office default open and
close times for all stores relative to the store?s own time zone for a
particular day.  

The second table represents the specific open and close time for a specific
store for a specific day, occasionally a store?s hours can be different from
the corporate default.

Table1:
open_time   timestamp
close_time   timestamp

Table2:
store_number   int
open_time    timestamp with timezone
close_time   timestamp with timezone


I would like to be able to initialize table 2 from table 1.

Suppose I had a store table that contained

Store_table:
Store_number   int
Store_tz             char(03)

I would like to do something like:

Insert into Table2
Select S.store_number  ,cast(T1.open_time  as timestamp with timezone at S.Store_tz) ,cast(T1.close_time as timestamp
withtimezone at S.Store_tz)
 
from Store_table S,  Table1 T1


-- 
View this message in context:
http://www.nabble.com/Assigning-a-timestamp-without-timezone-to-a-timestamp-with-timezone-tf2373845.html#a6613652
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: How to FindNearest
Next
From: Bryce Nesbitt
Date:
Subject: LOG: logger shutting down