dbTalk Databases Forums  

timestamptz insert

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss timestamptz insert in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Seader, Cameron
 
Posts: n/a

Default timestamptz insert - 01-19-2004 , 04:35 PM






hi,
I am having trouble with the following SQL insert

$createtbl = "CREATE TABLE $table (";
$createtbl .= "UTCTime timestamptz,";
$createtbl .= "error text,";
$createtbl .= "lowalarm bigint,";
$createtbl .= "highalarm bigint";
$createtbl .= "$points";
$createtbl .= ") ";

When i insert data into the timestamptz field it is automatically adding on
the time zone of MST which is not correct. The data that is being inserted
is not MST it is GMT. how do i make it insert as GMT.

note: it keeps the date and times the same, but it just adds the -07 to the
end of the timestamp. when it should accually just be adding -00 to the end
so that it stays in GMT format.

??? Do i need to do a SET timezone under psql on the database ???

Cameron Seader
Operations Center Technician II
CSeader (AT) Idahopower (DOT) com
1.208.388.2582 Office



[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. A2



---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: timestamptz insert - 01-19-2004 , 05:00 PM






"Seader, Cameron" <CSeader (AT) idahopower (DOT) com> writes:
Quote:
When i insert data into the timestamptz field it is automatically adding on
the time zone of MST which is not correct. The data that is being inserted
is not MST it is GMT. how do i make it insert as GMT.
You can either SET TIMEZONE TO 'GMT' or explicitly specify -00 in the
input data. If you want it to come back out in GMT then you will
definitely need to set the timezone value.

Realize that what is stored in the database is GMT in any case. If you
enter a timestamp that doesn't mention any particular zone, then it is
assumed to be in the zone specified by the timezone variable. In either
case, a non-GMT timestamp is then adjusted to GMT for storage. When the
value is displayed, it is adjusted back to the zone currently selected
by the timezone variable (which might or might not be the same as the
zone it was originally entered in). A little experimentation with
changing timezone and seeing how entry and output are affected should
make this clearer.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.