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

Double To Date Time Function
Dates Times Class

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

Converts the floating-point number of days since 12/30/1899 00:00 into a Date/time value.
This is different that using the CDate function to convert a Double to a Date because of the way that Microsoft represents pre-1900 dates.
Inverse of the DateTimeToDouble 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:
    CDate(-1.00) = #12/29/1899 00:00#
    CDate(-0.75) = #12/30/1899 18:00# ' Note
    CDate(-0.25) = #12/30/1899 06:00# ' Note
    CDate( 0.00) = #12/30/1899 00:00#
    CDate( 0.25) = #12/30/1899 06:00#
    CDate( 0.75) = #12/30/1899 18:00#
    CDate( 1.00) = #12/31/1899 00:00#
    DoubleToDateTime(-1.00) = #12/29/1899 00:00#
    DoubleToDateTime(-0.75) = #12/29/1899 06:00#
    DoubleToDateTime(-0.25) = #12/29/1899 18:00#
    DoubleToDateTime( 0.00) = #12/30/1899 00:00#
    DoubleToDateTime( 0.25) = #12/30/1899 06:00#
    DoubleToDateTime( 0.75) = #12/30/1899 18:00#
    DoubleToDateTime( 1.00) = #12/31/1899 00:00#
See also:
    DateTimeToDouble Function
vDate: The floating-point number of days since 12/30/1899 that will be converted back to Microsoft's representation for Date/time values. Function returns Null if vDate is Null or cannot be fixed up to a Date.

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