Hi Everyone,
I would like to get date and time from Epoch value such as:
1688750835759
will give date: 07JUL2023 and GMT time: 17:27:15.759
Can you please help?
Thank you so much.
HHC
data test;format epoch comma32.;
input epoch;
datalines;
1688750835759
;
run;
data test;set test;
*format dt datetime24.3;
drop dt seconds;
format date date9.;
format clock_time time9.;
seconds=epoch/1000;
dt = seconds + '01JAN1970:00:00'dt ;
date=datepart(dt);
clock_time=timepart(dt);
run;
Just convert the milliseconds to seconds and add the number seconds between 1960 and 1970.
251 data test; 252 epoch=1688750835759 ; 253 seconds=epoch/1000; 254 dt = seconds + '01JAN1970:00:00'dt ; 255 put epoch= comma32. / seconds=comma32.3 / dt=datetime24.3 ; 256 run; epoch=1,688,750,835,759 seconds=1,688,750,835.759 dt=07JUL2023:17:27:15.759
Just convert the milliseconds to seconds and add the number seconds between 1960 and 1970.
251 data test; 252 epoch=1688750835759 ; 253 seconds=epoch/1000; 254 dt = seconds + '01JAN1970:00:00'dt ; 255 put epoch= comma32. / seconds=comma32.3 / dt=datetime24.3 ; 256 run; epoch=1,688,750,835,759 seconds=1,688,750,835.759 dt=07JUL2023:17:27:15.759
Thank you so much, Tom.
HHC
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.