DaysAfter

Description

Determines the number of days one date occurs after another.

Syntax

DaysAfter ( date1, date2 )

Argument

Description

date1

A date value that is the start date of the interval being measured

date2

A date value that is the end date of the interval

Returns

Long. Returns a long whose value is the number of days date2 occurs after date1. If date2 occurs before date1, DaysAfter returns a negative number. If any argument’s value is null, DaysAfter returns null.

Examples

Example 1

This statement returns 4:

DaysAfter(2002-12-20, 2002-12-24)

Example 2

This statement returns -4:

DaysAfter(2002-12-24, 2002-12-20)

Example 3

This statement returns 0:

DaysAfter(2003-12-24, 2003-12-24)

Example 4

This statement returns 5:

DaysAfter(2003-12-29, 2004-01-03)

Example 5

If you declare date1 and date2 date variables and assign February 16, 2003, to date1 and April 28, 2003, to date2 as follows:

date date1, date2


date1 = 2003-02-16
date2 = 2003-04-28

Example 6

then each of the following statements returns 71:

DaysAfter(date1, date2)
DaysAfter(2003-02-16, date2)
DaysAfter(date1, 2003-04-28)
DaysAfter(2003-02-16, 2003-04-28)

See also