Function Dates Times Class

DecimalToHMS

"Decimal Degrees To Hours Minutes Seconds" Convert a decimal number of hours into number representing Hours, Minutes, and Seconds. Converts 12.5824388 hours into 12.345678 (representing 12h 34m 56.78s).

Signature (Visual Basic / VBA)

Public Function DecimalToHMS( _
    ByVal vDecimalHours As Variant _
    ) As Variant

Code Example

    DecimalToHMS(4.5555) = 4.33198
    DecimalToHMS( 4.76) =  4.4536
    DecimalToHMS(-4.76) = -4.4536

Parameters

Parameter Description
vDecimalHours A floating-point number which represents a number of hours. For example, .5 represents 1/2 hour or 30 minutes. Function returns Null if vDecimalHours is Null or cannot be fixed up to a number.

Return Value

The return value will (usually) be a number in which the integer part represents hours, the first two floating point digits represent minutes, the next two digits represent seconds, and the remaining digits represent a fractional number of seconds.