MindFusion.Reporting for Silverlight Programmer's Guide
DateDiff

Returns the number of intervals between two dates.

Syntax

 Copy Code

long DateDiff (
    string part,
    DateTime a,
    DateTime b
)

Parameters

part
String expression that is the interval you want to use to calculate the differences between a and b. See Remarks section for values.
a
A DateTime value.
b
A DateTime value.

Remarks

The part parameter can have one of the following values:

Parameter Value

Description

y

The returned value specifies the difference between a and b, expressed in years.

m

The returned value specifies the difference between a and b, expressed in months.

d

The returned value specifies the difference between a and b, expressed in days.

h

The returned value specifies the difference between a and b, expressed in hours.

n

The returned value specifies the difference between a and b, expressed in minutes.

s

The returned value specifies the difference between a and b, expressed in seconds.

You can use the DateDiff function to determine how many specified time intervals exist between two dates. For example, use DateDiff to calculate the number of days between two dates.

If a refers to a later point in time than b, the DateDiff function returns a negative number.

When comparing December 31 to January 1 of the immediately succeeding year, DateDiff for Year ("y") returns 1 even though only a day has elapsed.

See Also

Date & Time Functions
DateAdd Function
DatePart Function