<-- Previous || Up || Next -->

Date Time To Double Function
Dates Times Class

Public Function DateTimeToDouble( _
    ByVal vDateTime As Variant _
    ) As Variant

Takes a Date/time value an converts it into the floating-point number of days since 12/30/1899 00:00.
This is different that using the CDbl function to convert a Date to a Double because of the way that Microsoft represents pre-1900 dates.
Inverse of the DoubleToDateTime function.

Summary: Microsoft represents the date component of Date values as the integer number of days since 12/30/1899, and they represent the time component of Date values as the fractional part of the day since midnight on the Date. This is different than representing Date values as the floating-point number of days since 12/30/1899 because the day 12/30/1899 has two representations within the Microsoft scheme (-1 < Value <= 0 and 0 <= Value < 1). This causes problems if you do date arithmetic on pre-12/30/1899 dates. Sorting Date/time values whose dates are prior to 12/30/1899 will cause the values to be sorted incorrectly because of Microsoft's representation.
Examples:
    CDbl(#12/29/1899 00:00#) = -1
    CDbl(#12/29/1899 06:00#) = -1.25 ' Note
    CDbl(#12/29/1899 18:00#) = -1.75 ' Note
    CDbl(#12/30/1899 00:00#) =  0
    CDbl(#12/30/1899 06:00#) =  0.25
    CDbl(#12/30/1899 18:00#) =  0.75
    CDbl(#12/31/1899 00:00#) =  1
    DateTimeToDouble(#12/29/1899 00:00#) = -1
    DateTimeToDouble(#12/29/1899 06:00#) = -0.75
    DateTimeToDouble(#12/29/1899 18:00#) = -0.25
    DateTimeToDouble(#12/30/1899 00:00#) =  0
    DateTimeToDouble(#12/30/1899 06:00#) =  0.25
    DateTimeToDouble(#12/30/1899 18:00#) =  0.75
    DateTimeToDouble(#12/31/1899 00:00#) =  1
See also:
    DoubleToDateTime Function
vDate: The date whose time component is corrested if the date is prior to 12/30/1899. vDate is assumed to be a Date in Microsoft's representation. The return value is the floating-point number of days since 12/30/1899. Function returns Null if vDate is Null or cannot be fixed up to a Date.
Note: Function previously known as TrueDateTime.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.