Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating Time

Status
Not open for further replies.

MTBChik

Technical User
Jun 19, 2001
58
US
I am timing an event and need to calculate the runner's time back from the leader. The times are coming to me in string format as such "1:03:22.177".

In VBA, on the GroupHeader_Format Event, I'm trying to convert the winner's text box into a CDate

tmWinTime = CDate(me.txtResult)

but I keep getting a type mismatch error presumably from the .177. I know this, because if I truncate it to full seconds (1:03:22) it converts just fine.

Any thought on how to convert this so that I can subtract each runner's time from the winner's time and get the time back?

Muchas gracias all

MTBChik
'The day you stop riding, is the day you die'
 
tmWinTime = CDate(Left(Me!txtResult, InStr(Me!txtResult, ".") - 1))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH,

Great suggestion, however I need to include that .177 in the calculation. Your suggestion just truncates it (which is what I tried to do.)

If I do this in Excel and create a custom data type, then it will work. Is there anyway to create a custome date data type to accomplish the addition/subtraction?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top