DAYSBETWEEN
- DAYSBETWEEN(first_date, second_date)[source]
Returns the number of days between two dates.
The DAYSBETWEEN function calculates the difference in days between first_date and second_date. The result is positive if second_date occurs after first_date and negative if it occurs before. This function supports both single dates and arrays of dates.
- Parameters:
first_date (
Operand) –The starting date or array of dates.
Supported types:
DATE
DATETIME
DATE_ARRAY
DATETIME_ARRAY
second_date (
Operand) –The ending date or array of dates.
Supported types:
DATE
DATETIME
DATE_ARRAY
DATETIME_ARRAY
- Return type:
- Returns:
The number of days between the two dates. If input arrays have unequal lengths the returned formula will evaluate to an error.
Supported types:
INTEGER
INTEGER_ARRAY
- Raises:
ValueError – If either input is not a date or datetime type.
Examples
DAYSBETWEEN(DATE(2025, 1, 1), DATE(2025, 1, 10)) # Returns 9