View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default how do i convert data with miliseconds to just h:mm:ss

"bingo983" wrote:
i have time data with hours, minutes, seconds, and miliseconds. but in
order
to do my calculations, i need to drop the miliseconds. how can i format
this
data so it will only display h:mm:ss?
example: if a cell reads 12:34:55:789


It might be easier (and better) if you entered such time in a format that
Excel (but not VBA) supports, namely the custom format h:mm:ss.000 .

Then you could do your calculations directly (e.g. =A1+A2), without having
to "drop" the milliseconds. Just remember to propagate the custom format to
all cells involved in the calculation.

(Caveat: the direct calculation is subject to numerical abberations that
beset all computations involving decimal fractions. But that is true of the
h:mm:ss format as well.)

If you are interested in "dropping" milliseconds anyway, first you need to
decide if you want to truncate or round milliseconds.

To round, you could do:

=text(A1,"h:mm:ss") + text(A2,"h:mm:ss")

To truncate, you could do:

=(TEXT(A1,"h:mm")&LEFT(TEXT(A1,":ss.000"),3))
+ (TEXT(A2,"h:mm")&LEFT(TEXT(A2,":ss.000"),3))