Substract HH:MM from HH::MM and get HH:MM

Reply
New User
Posts: 1

Substract HH:MM from HH::MM and get HH:MM

Hi all, 

 

I am struggling with something that seems simple..

I got 2 columns...one is start time..other one is end time.

 

I have a 3rd column which is total time.

total time = end time - start time (in a formula)

Both start and end have HH:MM as a format.

 

But the Total time comes out just as HH and it rounds up. 

 

How can I make it so it shows me HH:MM in the total column?

 

Thanks

Respected Advisor
Posts: 4,820

Re: Substract HH:MM from HH::MM and get HH:MM

If both your time values are SAS time values, then calculating the difference is only a matter of substracting and applying the correct format to the result:

 

data _null_;
start_time = '14:30't;
end_time = '18:35't;
total_time = end_time - start_time;
format start_time end_time total_time hhmm6.;
put (start_time end_time total_time) (=/);
run;
PG
Ask a Question
Discussion stats
  • 1 reply
  • 159 views
  • 0 likes
  • 2 in conversation