Built-in Functions → daysBetween

daysBetween() is a scalar date function that returns the double number of days between two dates.

Note

day1 should be further ahead of in terms of time than day2. That is, day1 should be greater than day2.

Signature

daysBetween(date exp, date exp)

The following table illustrates the daysBetween() parameters:

ParameterDescription
date exp (1)one end of the range as a date
date exp (2)other end of the range as a date

Returns

int

Example

Find the number of days between December 24, 2001 11:55:12.00 pm and December 20, 2001 11:55:12.00.

daysBetween(timestamp("2001-12-24 23:55:12.000"),
timestamp("2001-12-20 23:55:12.000")))

In this example, the function returns 4 days, which is the number of days between the two dates.