vba display milliseconds high precision code example
Example: vba display milliseconds high precision
Select Range-->Format Cells-->Number-->Custom-->[hh]:mm:ss.000
[a1].NumberFormat = "[hh]:mm:ss.000"
Public Function FormatDatePrecision$(d#)
On Error Resume Next
FormatDatePrecision = Format(d / 86400, "yyyy-mm-dd HH:mm:ss")
FormatDatePrecision = FormatDatePrecision & "." & Split(d, ".")(1)
End Function
MsgBox FormatDatePrecision(3794741793.437)
Public Function CDatePrecision#(d$)
On Error Resume Next
CDatePrecision = CDbl(CDate(Split(d, ".")(0)) * 86400)
CDatePrecision = CDatePrecision + CCur(Split(d, ".")(1) / 1000)
End Function
MsgBox CDatePrecision("2020-03-30 14:56:33.437")