DiffDays

Use this function to determine the absolute number of days difference between two dates and return that value.

Syntax

DiffDays (Date1, Format1, Date2, Format2)

Parameter

Description

Date1

Enter a date string. The system assumes this date string is in the format specified by the Format1 parameter. The default is the current date.

Format1

Enter a date format string that describes the Date1 parameter. The default is date format 1 (MM/DD?YY).

Date2

Enter a date string. The system assumes this date string is in the format specified by the Format2 parameter. The default is the current date.

Format2

Enter a date format string that describes the Date2 parameter. The default is date format 1.

The system always returns a positive number regardless of which date string parameter is later in time. The result is always given in number of days regardless of the number of months and/or years that are included.

Example

Here are some examples:

(Assume the current date is 07/01/95.)

Function

Result

Explanation

DiffDays ("7/15/95")

14

The second parameter defaults to the current date. The resulting difference in days is 14.

DiffDays ("06/01 95", "1")

30

The second parameter defaults to the current date.

DiffDays ("October 31, 1961", "4", "10/31/95", "1")

12418

Note that two different date formats are used and that the result includes several years worth of days.

See also