HOURSBETWEEN

HOURSBETWEEN(first_time, second_time)[source]

Returns the number of hours between two times or arrays of times.

The HOURSBETWEEN function calculates the difference in hours between first_time and second_time. The result is positive if second_time occurs after first_time and negative if it occurs before. This function supports both single times and arrays of times. The return value is a decimal or decimal array representing the hour difference.

Parameters:
  • first_time (Operand) –

    The starting time or date time.

    Supported types:

    • TIME

    • DATETIME

    • TIME_ARRAY

    • DATETIME_ARRAY

  • second_time (Operand) –

    The ending time or date time.

    Supported types:

    • TIME

    • DATETIME

    • TIME_ARRAY

    • DATETIME_ARRAY

Return type:

Formula

Returns:

The number of hours between the two times. If input arrays have unequal lengths the returned formula will evaluate to an error.

Supported types:

  • DECIMAL

  • DECIMAL_ARRAY

Raises:

ValueError – If either input is not a valid type.

Examples

HOURSBETWEEN(TIME(14, 30, 0), DATE(16, 0, 0))
# Returns 1.5