The DiffHours function is a built-in function that returns the difference in hours between dt1 and dt2; i.e. how many hours have passed between these two dates. Returns a positive number if dt1 is smaller than dt2; and returns a negative number if dt1 is bigger than dt2.

The DiffHours 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 DiffDays, 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

DiffHours( #1982-05-21 22:20:30#, #1982-05-22 02:00:00# )

4

DiffHours( #1982-05-22 02:00:00#, #1982-05-21 22:20:30# )

-4

DiffHours( #2005-05-11 10:59:00#, #2005-05-11 10:00:00# )

0

DiffHours( #2005-05-11 10:00:00#, #2005-05-12 10:00:00# )

24

DiffHours( #2005-05-11 10:59:00#, #2005-05-12 15:00:00# )

29

 

DiffHours( #2006-03-25 15:00:00#, #2006-03-26 15:00:00# )

24 (in a .NET application server) or 23 (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 2006 Daylight Saving Time starts in Europe on March 26 of 2006.

DiffHours( #2006-10-28 15:00:00#, #2006-10-29 15:00:00# )

24 (in a .NET application server) or 25 (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 2006 Daylight Saving Time ends in Europe on October 29 of 2006.

Remarks

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

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

See Also

Available Data and Time Functions | Available Built-in Functions