BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Barite | Level 11

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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
hhchenfx
Barite | Level 11

Thank you so much, Tom.

HHC

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 350 views
  • 1 like
  • 3 in conversation