473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 4614
CSN <co*******************@yahoo.com> 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.com> 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
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...
2
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...
2
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...
3
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
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...
1
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...
1
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
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...
7
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.