Skip to content

SpanHours

See Also: Time and Date Functions

Purpose

Returns the hours component of the given TimeSpan variable tsVar.

Return Type

Integer

Syntax

(SpanHours({tsVar}))

Where:

What it Does

The SpanHours function returns the hours component of the given TimeSpan variable tsVar.

Example

This sample shows the total time that has passed since 12/31/2007 at one second before midnight.

Procedure TestSpanMilliSeconds
    DateTime dtVar1 dtVar2
    TimeSpan tsVar

    // Set dtVar1 to 12/31/2007, 11:59:59.01 PM
    Move (DateSetYear(dtVar1, 2007)) to dtVar1
    Move (DateSetMonth(dtVar1, 12)) to dtVar1
    Move (DateSetDay(dtVar1, 31)) to dtVar1
    Move (DateSetHour(dtVar1, 23)) to dtVar1
    Move (DateSetMinute(dtVar1, 59)) to dtVar1
    Move (DateSetSecond(dtVar1, 59)) to dtVar1
    Move (DateSetMillisecond(dtVar1, 10)) to dtVar1
    Move (CurrentDateTime()) to dtVar2
    Move (dtVar1 - dtVar2) to tsVar

    Showln "The time passed between " dtVar1 " and " dtVar2 " is"
    Show (SpanDays(tsVar)) " days, "
    Show (SpanHours(tsVar)) " hours, "
    Show (SpanMinutes(tsVar)) " minutes, "
    Show (SpanSeconds(tsVar)) " seconds and "
    Showln (SpanMilliseconds(tsVar)) " milliseconds"
End_Procedure

Notes