Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
Timezone woes.
Old
  (#1)
Guest
Guest
 
Posts: n/a
Default Timezone woes. - 06-04-2007, 07:45 AM

Here's the situation:

I am running queries against a set of databases that all reside on
different Linux nodes that are within different timezones (We'll call
them "remote0x"). I need to port the data from these databases to a
local database ("local01"). The script needs to portable to run on
nodes in any timezone.

Ideally, I'd like to store the dates for all of the data in UTC. So if
I have a UTC datetime, how can I select records from the remote DBs
using UTC?


Example:
--------------------------
local01 - timezone=CST
remote01 - timezone=PST
remote02 - timezone=EST

Let's ***ume the local datetime is 2007-01-09 08:10

local01 - Query to get current UTC time:
SELECT UTC_TIMESTAMP();
-> 2007-01-09 14:10

remote01 - Query to select records with UTC timestamp returned above
(essentially, 2007-01-09 06:10 according to its timezone):
SELECT field1,field2,etc,? FROM exampleTable WHERE ?='2007-01-09
14:10';
-> field1,field2,etc,2007-01-09 14:10

remote02 - Query to select records with same UTC timestamp ( 2007-01-09
09:10 according to its timezone):
SELECT field1,field2,etc,? FROM exampleTable WHERE ?='2007-01-09
14:10';
-> field1,field2,etc,2007-01-09 14:10
--------------------------

It's imperative that I write this with the ***umption that I'll have no
way of knowing the TZ of each remote instance.

For the record, the local box is running MySQL 5.1 and the remotes are
still on 4.1.

What's the simplest way to get to what I'm looking for?

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top