The DiffDays function is a built-in function that returns the difference in days between two dates, dt1 and dt2:

The Time component you provide in the parameters will be ignored. The DiffDays function receives two Date Time parameters, and then replaces the Time component with 00:00:00. It calculates the elapsed time in milliseconds from the first date at 00:00:00 to the second date at 00:00:00, and then converts the difference in milliseconds into days.

The DiffDays function behaves differently depending on the application server you are using because Daylight Saving Time (DST) is considered in the J2EE server while in the .NET server DST is ignored. Note that the time zone considered for evaluating this function is always the time zone of the Platform Server, regardless of the regional setting of the end-user desktop. The DiffHours, DiffMinutes and DiffSeconds functions also behave like this function.

Input parameters

dt1: Date Time Type

dt2: Date Time Type

Output parameters

Integer Type

Examples

Usage

Result

DiffDays( #1982-05-19#, #1982-05-21# ) 2
DiffDays( #1982-05-21#, #1982-05-19# ) -2

DiffDays( #2005-05-11 00:00:00#, #2005-05-11 23:59:59# )

0

DiffDays( #2004-09-01#, #2004-10-01# )

31

DiffDays( #2004-09-01 23:00:00#, #2004-09-02 00:10:00# )

1

DiffDays( #2004-09-01 23:00:00#, #2004-09-02 23:30:00# )

1

DiffDays( #2014-03-30 00:00:00#, #2014-03-31 00:00:00# )

1 (in a .NET application server) or 0 (in a J2EE application server), assuming the GMT + 1hour time zone. If your server is in a different time zone, you will get different results.

Note that 2014 Daylight Saving Time starts in Europe on March 30 of 2014.

DiffDays( #2014-10-25 00:00:00#, #2014-10-26 00:00:00# )

1, assuming the GMT + 1hour time zone. If your server is in a different time zone, you will get different results.

Note that 2014 Daylight Saving Time ends in Europe on October 26 of 2014.

Remarks

When using this function you must be aware that the maximum value supported by Service Studio is (2 ^ 31) -1 days. This corresponds to, approximately, 5879489.8 years, which is probably within the typical dates that you might handle.

If DiffDays (dt1, dt2) is bigger than 2147483647, you will get an unexpected value.

See Also

Available Data and Time Functions | Available Built-in Functions