From: db on
Hi, I have a dataset that has Greenwich time (GMT) with GMT_Offset. I
need to convert GMT to CST (Central Standard Time) by using gmt_offset
var. But I get a problem when gmt is between 00:00 and 05:59, which
gives me a negative time,and wrong minute. Could you please help me on
this logic ? Thanks, db

data test;
input gmt :time5.
gmt_offset ;
cst=gmt+(60*60*(gmt_offset));
cards;
7:30 -6
12:02 -6
16:09 -6
00:06 -6
01:09 -6
02:40 -6
05:59 -6
;
proc print data=test;
format gmt cst time5.;
run;
From: Lou on

"db" <daronnebonneau(a)gmail.com> wrote in message
news:74f41680-3add-4a83-b8fa-14fbc87d7dc3(a)z3g2000yqz.googlegroups.com...
> Hi, I have a dataset that has Greenwich time (GMT) with GMT_Offset. I
> need to convert GMT to CST (Central Standard Time) by using gmt_offset
> var. But I get a problem when gmt is between 00:00 and 05:59, which
> gives me a negative time,and wrong minute. Could you please help me on
> this logic ? Thanks, db
>
> data test;
> input gmt :time5.
> gmt_offset ;
> cst=gmt+(60*60*(gmt_offset));
> cards;
> 7:30 -6
> 12:02 -6
> 16:09 -6
> 00:06 -6
> 01:09 -6
> 02:40 -6
> 05:59 -6
> ;
> proc print data=test;
> format gmt cst time5.;
> run;

There's nothing really "wrong" about the negative times you're getting. For
instance, it's an indication that 05:59 GMT is one minute before midnight
CST, or to put it another way, the CST time is 23:59 (the date for this time
is the previous GMT day). To convert negative time values to 24 hour clock
values, you'll need to do something like:

IF CST < 0 THEN CST = (60*60*24) + CST;

Just remember that if you have a date value that accompanies the time value,
you'll have to decrement the date by one day as well.


From: db on
Thanks !
On Apr 19, 5:58 am, "Lou" <lpog...(a)hotmail.com> wrote:
> "db" <daronnebonn...(a)gmail.com> wrote in message
>
> news:74f41680-3add-4a83-b8fa-14fbc87d7dc3(a)z3g2000yqz.googlegroups.com...
>
>
>
>
>
> > Hi, I have a dataset that has Greenwich time (GMT) with GMT_Offset. I
> > need to convert GMT to CST (Central Standard Time) by using gmt_offset
> > var. But I get a problem when gmt is between 00:00 and 05:59, which
> > gives me a negative time,and wrong minute. Could you please help me on
> > this logic ?  Thanks, db
>
> > data test;
> > input gmt :time5.
> >      gmt_offset ;
> >      cst=gmt+(60*60*(gmt_offset));
> > cards;
> > 7:30 -6
> > 12:02 -6
> > 16:09 -6
> > 00:06 -6
> > 01:09 -6
> > 02:40 -6
> > 05:59 -6
> > ;
> > proc print data=test;
> > format gmt cst time5.;
> > run;
>
> There's nothing really "wrong" about the negative times you're getting.  For
> instance, it's an indication that 05:59 GMT is one minute before midnight
> CST, or to put it another way, the CST time is 23:59 (the date for this time
> is the previous GMT day).  To convert negative time values to 24 hour clock
> values, you'll need to do something like:
>
> IF CST < 0 THEN CST = (60*60*24) + CST;
>
> Just remember that if you have a date value that accompanies the time value,
> you'll have to decrement the date by one day as well.- Hide quoted text -
>
> - Show quoted text -