Hi ,I want to convert Date_time character variable(IST) to EST (date and time format) .please help me.
original_date | time_ist | Date_time |
28/12/2016 | 3:06:36 | 28DEC2016/3:06:36 |
11/11/2016 | 19:56:35 | 11NOV2016/19:56:35 |
11/11/2016 | 19:55:58 | 11NOV2016/19:55:58 |
11/11/2016 | 19:53:25 | 11NOV2016/19:53:25 |
11/11/2016 | 19:55:26 | 11NOV2016/19:55:26 |
11/11/2016 | 19:51:53 | 11NOV2016/19:51:53 |
11/11/2016 | 19:52:25 | 11NOV2016/19:52:25 |
16/11/2016 | 14:00:56 | 16NOV2016/14:00:56 |
16/11/2016 | 13:25:02 | 16NOV2016/13:25:02 |
16/11/2016 | 15:23:54 | 16NOV2016/15:23:54 |
16/11/2016 | 14:00:18 | 16NOV2016/14:00:18 |
16/11/2016 | 13:08:55 | 16NOV2016/13:08:55 |
16/11/2016 | 16:21:36 | 16NOV2016/16:21:36 |
Thanks,
Siva
Well, IST is UTC+5:30, while ET (or EST) is UTC-5, so we have to subtract 10:30 from IST time to get the correct timestamp for ET:
data want;
input date_time :$20.;
dt_time = input(date_time,datetime20.);
format dt_time e8601dt20.;
dt_time = dt_time - '10:30:00't;
cards;
28DEC2016/3:06:36
11NOV2016/19:56:35
11NOV2016/19:55:58
11NOV2016/19:53:25
11NOV2016/19:55:26
11NOV2016/19:51:53
11NOV2016/19:52:25
16NOV2016/14:00:56
16NOV2016/13:25:02
16NOV2016/15:23:54
16NOV2016/14:00:18
16NOV2016/13:08:55
16NOV2016/16:21:36
;
run;
You now have a datetime value for Eastern Time, and can use datepart() and timepart() to extract the ET date and time values from that.
Do
data want;
set have;
original_date = datepart(input(date_time,datetime20.));
time_ist = timepart(input(date_time,datetime20.));
format
original_date ddmmyy10.
time_ist time8.
;
run;
Thanks sir.
Consulting wikipedia, the only date/time-related uses of the acronym EST are Eastern Standard Time and European Summer Time. Do you want to factor in a timezone?
Otherwise describe how the final variable should be formatted. When dealing with such values, it's usually best to keep the value as a true SAS datetime value (seconds from 1960-01-01T00:00:00) and use an appropriate format (you can even create a custom one yourself).
original_date | time_ist |
28/12/2016 | 3:06:36 |
Here original date is 28/12/2016 and ist time is 3:06:36 which is Indian Standard Time (IST), I want to convert it to 27/12/2016 and 17:06:36 Estern Standard Time (EST (USA/Canada)).
Well, IST is UTC+5:30, while ET (or EST) is UTC-5, so we have to subtract 10:30 from IST time to get the correct timestamp for ET:
data want;
input date_time :$20.;
dt_time = input(date_time,datetime20.);
format dt_time e8601dt20.;
dt_time = dt_time - '10:30:00't;
cards;
28DEC2016/3:06:36
11NOV2016/19:56:35
11NOV2016/19:55:58
11NOV2016/19:53:25
11NOV2016/19:55:26
11NOV2016/19:51:53
11NOV2016/19:52:25
16NOV2016/14:00:56
16NOV2016/13:25:02
16NOV2016/15:23:54
16NOV2016/14:00:18
16NOV2016/13:08:55
16NOV2016/16:21:36
;
run;
You now have a datetime value for Eastern Time, and can use datepart() and timepart() to extract the ET date and time values from that.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.