Hello,
I have two seperate fields for date and time. I want to combine them to use for sorting purposes.
The time begins with SQLs start date as shown (01JAN1900) in the time coloumn.
SQL_DATE MILITARY_TIME Identifier WANT (datetime)
11DEC2021:00:00:00 01JAN1900:16:56:00:000 ID1 11DEC2021:16:56:00
11DEC2021:00:00:00 01JAN1900:23:46:00:000 ID1 11DEC2021:24:36:00
Thank you
datetime=dhms(datepart(sql_date),hour(timepart(military_time)),minute(timepart(military_time)),0);
Alternative:
datetime2=sql_date+(military_time-'01JAN1900:00:00:00'dt);
Use the DHMS() function. Pass the DATE from the one DATETIME value as the DAYS argument and the TIME from the other DATETIME value as the SECONDS value.
want=dhms(datepart(SQL_DATE),0,0,timepart(MILITARY_TIME));
Make sure to attach a datetime type format to the new WANT variable so the values print in the way humans will recognize as datetime values.
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 16. 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.