BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

Hi all,

 

I have a date and time fields, both are Text data type

 

C_Date looks like 18/06/19  (YY/MM/DD)

C_Time looks like 12:30:48

 

I need to convert the above 2 text fields into one DateTime field (datetime20.), like 19JUN2019:12:30:48

 

 

Thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data test;
C_Date='18/06/19';
C_Time='12:30:48';
N_date=input(c_date, yymmdd8.);
N_time=input(c_time, time8.);
N_datetime=dhms(N_date,0,0,0)+N_time;
format N_datetime datetime20.;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20
data test;
C_Date='18/06/19';
C_Time='12:30:48';
N_date=input(c_date, yymmdd8.);
N_time=input(c_time, time8.);
N_datetime=dhms(N_date,0,0,0)+N_time;
format N_datetime datetime20.;
run;
ballardw
Super User

In a data step this should work.

 

cdt = dhms(input(c_date,yymmdd8.),0,0,input(c_time,time8.));

format cdt datetime18.;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 856 views
  • 2 likes
  • 3 in conversation