Example 1:

Use DateDiff() with the "d" or "y" interval type parameter to find the number of days between two dates:

DateDiff("d", #10/7/1999#, #10/10/1999#)

Returns 3

Example 2:

Use DateDiff with the "yyyy" interval type parameter to find the number of years difference between two dates. This use of DateDiff is the same as finding the difference between the year of endDateTime and the year of startDateTime.

DateDiff ("yyyy", #10/7/1999#, #2/10/2005#)

Returns 6
 

DateDiff (intervalType, startDateTime, endDateTime, firstDayOfWeek)

  • intervalType is a String expression that is the interval of time you use to calculate the difference between startDateTime and endDateTime.
  • startDateTime is the first DateTime value used in calculating the difference.
  • endDateTime is the second DateTime value used in calculating the difference.
  • firstDayOfWeek is an optional constant specifying the first day of the week. If not specified, crSunday is assumed.

Function Description:

DateDiff returns a number of time intervals between two specified dates.

For additional information and examples on formula functions, please go to Help, and Crystal Reports Help from within the Crystal Reports program.