Discussion:
Converting GMT to EST
(too old to reply)
Mona
2007-11-01 20:01:03 UTC
Permalink
Hi All,
Is there a way to convert GMT time to EST time.I tried using intnx but
haven't had much success.


Thanks
Chang Chung
2007-11-01 20:11:09 UTC
Permalink
Post by Mona
Hi All,
Is there a way to convert GMT time to EST time.I tried using intnx but
haven't had much success.
EST = GMT-5 during the winter. See Wikipedia article on ETS at
http://en.wikipedia.org/wiki/North_American_Eastern_Time_Zone
Terjeson, Mark
2007-11-01 20:13:37 UTC
Permalink
Hi Mona,

Since time is stored as number of seconds,
and since INTNX rounds to the hour when
you are incrementing by 'hour' then this
will work just fine: (offset timezone diff
by the number of hours converted to seconds)


data _null_;
gmt = '20:05:09't;
est = gmt - (4*60*60);
pst = gmt - (7*60*60);
format _all_ time.;
put _all_;
run;




Hope this is helpful.


Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investments


Russell Investments
Global Leaders in Multi-Manager Investing






-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU] On Behalf Of
Mona
Sent: Thursday, November 01, 2007 1:01 PM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Converting GMT to EST

Hi All,
Is there a way to convert GMT time to EST time.I tried using intnx but
haven't had much success.


Thanks
Renee Jaramillo
2007-11-01 21:52:33 UTC
Permalink
One word of caution – since EST is 5 hours behind GMT, when you subtract 5
hours from GMT, that may put you in the previous day. So if you have date
information in addition to time, you may need to adjust the date as well.

For converting between time zones what I always do is: (1) create a
datetime variable of my existing data, (2) add or subtract hours as needed
for the new timezone, and (3) split out the new date and time into separate
variables. Like this:

*** GENERATE TEST DATA WITH 24 HOURS FOR ONE DAY ***;
data times;
do hour = 0 to 23;
gmt=hms(hour,5,0);
output;
end;
format gmt time5. ;
run;

title 'THIS EXAMPLE WILL PRODUCE NEGATIVE TIMES';
data example1;
set times;
est=gmt-(5*60*60);
format est time5. ;
run;
proc print data=example1;
run;


title 'THIS EXAMPLE WILL ADJUST TO THE PREVIOUS DAY AS NEEDED';
data example2;
set times;
*** IF YOU DO NOT HAVE THE GMT DATE IN YOUR DATASET, TEMPORARILY
USE TODAYS DATE ***;
gmt_date=today();
*** COMBINE GMT DATE AND TIME INTO A DATETIME VARIABLE ***;
gmt_datetime=dhms(gmt_date,0,0,gmt);

*** CONVERT DATETIME VARIABLE FROM GMT TO EST ***;
est_datetime=gmt_datetime - 5*60*60;
*** FOR EST - SPLIT OUT THE DATE AND TIME ***;
est=timepart(est_datetime);
est_date=datepart(est_datetime);

*** DROP UNNEEDED VARIABLES ***;
drop gmt_datetime est_datetime;

format gmt est time5. gmt_date est_date mmddyy10.;
run;
proc print data=example2;
run;




Here is a good website with tables to convert between GMT and timezones in
North America for both standard time and daylight savings time:
http://atm.geo.nsf.gov/ieis/time.html


Hope this helps,
Renee
Howard Schreier <hs AT dc-sug DOT org>
2007-11-02 17:37:24 UTC
Permalink
Post by Chang Chung
Post by Mona
Hi All,
Is there a way to convert GMT time to EST time.I tried using intnx but
haven't had much success.
For datetimes: est = intnx('second',gmt,-'5:00't);

For times: est = mod(intnx('second',gmt,-'5:00't)+'24:00't,'24:00't);
Post by Chang Chung
EST = GMT-5 during the winter. See Wikipedia article on ETS at
http://en.wikipedia.org/wiki/North_American_Eastern_Time_Zone
I believe EST = GMT-5 at all times. For part of each year, most places in
the Eastern Time Zone adopt EDT, which is GMT-4 or EST+1.

Loading...