473,738 Members | 7,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

update time zone in timestamps

CSN
Is it possible to update the timezone part of
timestamp fields in a single query? I have a bunch of
values that are -06 I need changed to -07.

BTW, better to use 'timestamp without time zone' or
'timestamp with time zone'?

_______________ _______________ ____
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
2 4646
CSN <co************ *******@yahoo.c om> writes:
Is it possible to update the timezone part of
timestamp fields in a single query? I have a bunch of
values that are -06 I need changed to -07.


I suspect that you have a fundamental conceptual error.

You cannot "update the timezone" because the timezone is not part of the
stored value; it is part of the display operation. Stored values for
timestamptz columns are always effectively in UTC. When the value is
converted to a string for display, it is adjusted to your current local
timezone (per SET TIME ZONE) and that timezone is what's put on the
output.

So the basic answer is you don't change the data, you change your
TIME ZONE setting from -6 to -7 if that's what you want to see.

You might have an additional problem that the data was entered
incorrectly, and is one hour off from reality because you were
confused about time zones when you put it in. In that case you'd
fix it with something like
UPDATE tab SET col = col + '1 hour'::interval ;

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #2
CSN

Does Postgres use the system's timezone
(/etc/localzone) at all? Or does "SET TIME ZONE 'MST'"
need to be placed in postgres.conf to make it always
used (I set it via psql, but it appears to only be set
for that connection)?

Thanks,
CSN
--- Tom Lane <tg*@sss.pgh.pa .us> wrote:
CSN <co************ *******@yahoo.c om> writes:
Is it possible to update the timezone part of
timestamp fields in a single query? I have a bunch

of
values that are -06 I need changed to -07.


I suspect that you have a fundamental conceptual
error.

You cannot "update the timezone" because the
timezone is not part of the
stored value; it is part of the display operation.
Stored values for
timestamptz columns are always effectively in UTC.
When the value is
converted to a string for display, it is adjusted to
your current local
timezone (per SET TIME ZONE) and that timezone is
what's put on the
output.

So the basic answer is you don't change the data,
you change your
TIME ZONE setting from -6 to -7 if that's what you
want to see.

You might have an additional problem that the data
was entered
incorrectly, and is one hour off from reality
because you were
confused about time zones when you put it in. In
that case you'd
fix it with something like
UPDATE tab SET col = col + '1 hour'::interval ;

regards, tom lane

_______________ _______________ ____
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6770
by: Jason Priebe | last post by:
I'm a bit confused about SET TIME ZONE and its effect on PostgreSQL's date processing. In my experience with timestamps in all other *nix-based software systems, a timestamp is always a numeric representation of the time elapsed since the epoch, in GMT. Thus, a function that returns the current timestamp should always return the same value, regardless of timezone. The display of that value may change based on the system's timezone,...
2
6304
by: MLH | last post by:
I would like to be able to look up any 5-digit ZIP in a table that would show the correct time zone for the area. For example, I would like to look up 91915 in the table and see something that indicates Pacific Time Zone or 27615\ would be found as Eastern Time Zone. I guess I want Eastern Time Zone, Central Time Zone, Mountain Time Zone, Pacific Time Zone, Atlantic Time Zone along with Palau, Hawaii, Guam and all the others for the...
2
5472
by: Tee GEE | last post by:
I would like a user to input a time from a dropdown menu and have the three other fields update to the corresponding time zone. For example: a user in PST selects 0800 from the menu. The other three field then automatically update to 0900 MST, 1000 CST, and 1100 EST. Thanks for the help. Please email any code the the email provided. Tom *** Sent via Developersdex http://www.developersdex.com ***
3
35096
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
2
24626
by: Avi | last post by:
I have a problem to get the different time zone's name for example I need the name of time zone UTC + 4:30 ("Kabul") The TimeZone.CurrentTimeZone get my current time zone name and I couldn't see how to get a different time zone name please hlp this is very important. Avi
1
2328
by: Clodoaldo Pinto Neto | last post by:
Hi all, I want to have the time zone string (like 'BRT') displayed after a date-time. The date column is of the type timestamp with time zone. But the time zone is not displayed. It works for a timestamp without time zone column: # select to_char(timestamp '2001-02-16 20:38:40' at time zone 'BRT', 'HH24:MI DD/MM/YYYY TZ'); to_char
1
8267
by: Michael Barrido | last post by:
please help. I want to be able to change my computer's system "Time Zone" via vb.net code. is it possible? -mike
3
2747
by: Satish Itty | last post by:
Hi all, I have a big problem in my hands and not sure how I can fix this. Any suggestions would be greatly appreciated. I have a .NET 3 tier app developed in VS2003 and .NET 1.1. the client is a windows application and middle tier runs on IIS. Data is passed between the client and middle tier as DataSets and custom value object classes. The problem in my hand is that the client application is deployed in different time zones and the...
7
5508
by: Steve | last post by:
Hi All I have a windows application written in VB.net 2005 The users have to select a State of Australia, which I use to check they have the correct windows time zone selected in control panel Dim myzone As TimeZone = TimeZone.CurrentTimeZone If they change the Time zone whilst my application is running, a new call to Dim myzone As TimeZone = TimeZone.CurrentTimeZone returns the same time zone NOT the new one They have to restart my...
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.