BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

hello,

 

please help

 

Have start_time and end_time in date format and need difference in hh:mm:ss 

 

have 

start_time          end_time

  3:00:00            5:00:00

21:00:00          25:10:23

16:25:00          18:50:10

20:15:34          20:16:50 

21:00:00            1:25:55 /*here end_time is next day time*/

 

want

time_difference

2:00:00            

4:10:23         

2:25:23          

0:01:16         

4:25:55

 

 

below logic is working fine but not for last record, it is giving negative number becasue end_time is in next day

time_difference=end_time-start_time;

format time_difference time8.;

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star
if end_time - start_time < 0 then time_difference = end_time - start_time + '24:00:00't;
else time_difference = end_time - start_time; 

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star
if end_time - start_time < 0 then time_difference = end_time - start_time + '24:00:00't;
else time_difference = end_time - start_time; 
woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10
Thanks SAS KIWI - it worked fine, appreciate your time

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 914 views
  • 0 likes
  • 2 in conversation