12345
12345

Reputation: 67

Clarification regarding gmtoff

I have two line below

 %let dl="06jul2016"
 date=dhms("&dl",d,00,00,00);
 date1=dhms("&dl",d,00,00,00)-gmtoff();
 date2=dhms("&dl",d,24,00,00)-gmtoff();

Output

date=2016-07-06T00:00:00
date1=2016-07-06T04:00:00
date2=2016-07-06T04:00:00

Could anyone explain me the result.

Thannkyou

Upvotes: 0

Views: 253

Answers (2)

Jetzler
Jetzler

Reputation: 797

gmtoff() is a correction function for Greenwich Mean Time. So depending on your computers timezone, the results will differ. The input time is GMT and depending on your local timezone x hours are added/substracted. As you are using-gmtoff() you are subtracting the correction factor. That may produce unwanted results.

Also date1 & date2 should produce a difference of one day. Something seems off with your output.

Upvotes: 0

user667489
user667489

Reputation: 9569

I was not able to reproduce your output. After tidying up your code, I got some slightly different output:

Code:

%let dl="06jul2016"d;
data _null_;
date=dhms(&dl,00,00,00);
date1=dhms(&dl,00,00,00)-gmtoff();
date2=dhms(&dl,24,00,00)-gmtoff();
format  date: is8601dt.;
put (_all_) (=/);
run;

Output:

 date=2016-07-06T00:00:00
 date1=2016-07-06T00:00:00
 date2=2016-07-07T00:00:00

Is that closer to what you were expecting?

Upvotes: 1

Related Questions