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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Milliseconds Format Covertion 1

Status
Not open for further replies.

cass60660

Programmer
Joined
Nov 13, 2002
Messages
30
Location
US
I have a time format like : hh:mm:ss.ms
where ms are milliseconds.
I wand to run a DateAdd(IntervalType, Number, FirstDate) where first date is like : mm/dd/yy hh:mm:ss.ms and I receive type mismatch error.
How to convert time into hh:mm:ss, so no milliseconds to make this work.
All it is a VBA Application.

Thank you.
 
Try This

DateAdd(IntervalType, Number, Format(FirstDate, "mm/dd/yy hh:mm:ss"))
 
Nope. Is not working.
type mismatch -> error
 
You are going to have to "chop off" the last 3 characters....
 
That seems to be the only solution.
I will use Split function whith "." as delimiter.
Do you know something else better to chop the last chars.?
 

Ok, try something like...
[tt]
Option Explicit

Private Sub Form_Load()

Dim D As Date, VV
VV = "04:05:22.233"

D = RemoveMiliSeconds(VV)

MsgBox D

VV = "14:05:22.233"

D = RemoveMiliSeconds(VV)

MsgBox D

End Sub

Public Function RemoveMiliSeconds(VariantVariable) As Date

RemoveMiliSeconds = CDate(Left(VariantVariable, InStr(1, VariantVariable, ".") - 1))

End Function
[/tt]
to get the format you want then you can do your operation.

Good Luck

 

This is much better.
Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top