Google

How to convert .NET DateTime to Variant Time in VBA
 

How to convert .NET DateTime to Variant Time in VBA

Posted on Nov 6, 2007 5:39 pm PST  -  Contact the poster  -  Report bad item

Details

Author:   Kasajian
Publication Name:   Kasajian
Publish Date:   May 18, 2007
 

Description

Public Function DotNetDateTimeToVBTime(ByVal inDotNetDateTimeInTicks As Double) As Date
    On Error GoTo finish
   
    Const hundrednanosecondsPerSecond = 10000000
    Const vbEpochInDotNetDateTimeTicks = 5.99264352E+17
   
    Dim diffTicks As Double: diffTicks = inDotNetDateTimeInTicks - vbEpochInDotNetDateTimeTicks
    Dim dSeconds As Double: dSeconds = diffTicks / hundrednanosecondsPerSecond
    Dim dStart As Double: dStart = dSeconds / (60# * 60# * 24#)
    Dim vbResult As Date: vbResult = dStart
   
    DotNetDateTimeToVBTime = vbResult
finish:
End Function

 

Contact

Name: Kenneth Kasajian
Contact the poster