dbTalk Databases Forums  

Timezone woes.

comp.databases.mysql comp.databases.mysql


Discuss Timezone woes. in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
darenbell@gmail.com
 
Posts: n/a

Default Timezone woes. - 01-09-2007 , 09:03 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 assume 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 assumption 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?


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.