Functions and operators : DIFF_QUARTER( )

DIFF_QUARTER( )

Calculates the number of quarters between two date values.

Syntax

DIFF_QUARTER(date1, date2)

Arguments

date1

The first date or date expression to use in the calculation.

date2

The second date or date expression to use in the calculation.

Returns

The number of quarters between date1 and date2. DIFF_QUARTER calculates the difference by subtracting the month number of date1 from the month number of date2. A difference of 3 months is equal to 1 quarter. For example, if date1 is 8/1/08 and date2 is 10/31/08, DIFF_QUARTER( ) returns 0. If date1 is 8/25/08 and date2 is 11/5/08, DIFF_QUARTER( ) returns 1.

Example

The following example calculates the number of quarters between each value in the PlanClosing data field and each value in the ActualClosing data field.

DIFF_QUARTER([PlanClosing],[ActualClosing])

The following example calculates the number of quarters from each value in the orderDate data field to the end of the year.

DIFF_QUARTER([orderDate], "1/1/09")