11-03-2015 10:58 AM
i have a variable of time, such as 08:25:46.87. i need to find difference between two times and want to know total milliseconds.
i found function INTCK, but i don't have there milliseconds.
what i should do?
what do you thins about the next solution : if i got that difference between two times is : 00:02:37.44, i can convert minutes to seconds and get total seconds 157 and to multiply it by 1000(1 seconds=1000milliseconds), and then add 440 seconds(44*1000/100)?
11-03-2015 11:34 AM
11-03-2015 11:01 AM
Time is stored as the number of seconds since midnight. If you have milliseconds or other fractions of a second then they will be there as the fractional part of the number. To find the difference between two times just subtract them.
To express the result in millisecond just mulitple by 1,000.
11-03-2015 11:30 AM
thank you. as i understand you, the number after dot, is number of seconds and not milliseconds and the maximum can be 100.(i never see more than 100). i have to substract only two numbers, and the result multiply by 1000?
for example :
08:20:41.87-08:20:40.47=00:00:01.40(one seconds and 41 number of seconds)
11-03-2015 11:34 AM
11-03-2015 11:45 AM
If you did not collect milliseconds then you probably do not have them. But perhaps you are just seeing two decimal places because of the format attached to the variable.
data _null_; t1= '08:20:41.87't ; t2= '08:20:40.47't ; s = t1-t2 ; ms = s*1000; put (t1 t2 s) (= time12.3 /); put (t1 t2 s ms) (= /); run;
t1=8:20:41.870 t2=8:20:40.470 s=0:00:01.400 t1=30041.87 t2=30040.47 s=1.4 ms=1400
11-03-2015 11:47 AM
Displayed values really depend on the format. If you use a datetime with no decimal part you won't see any fraction of a second.
Look in the log at the results of this example with different formats.
data _null_; x = "10JAN2015:10:15:23.123456"dt; put x datetime22.; put x datetime22.1; put x datetime22.2; put x datetime22.3; put x datetime22.4; put x datetime22.5; run;
Need further help from the community? Please ask a new question.