Broken DiffHours function?

Broken DiffHours function?

Hey everyone ... I'm trying to use the DiffHours function, unfortunately it's not working as described:

DiffHours(#2013-08-16 09:59:00#, #2013-08-16 10:01:00#) returns 1, although clearly 0 hours (and 2 minutes) have passed between the two dates.

Does anybody else battle with this issue? Does DiffHours not use the date difference, but the hour cutoff?


Hello Stefan,

When calculating the difference in hours between two dates, the OutSystems Platform is indeed cutting of the minutes and seconds before calculating the difference. So your call is equivalent to:

DiffHours(#2013-08-16 09:00:00#, #2013-08-16 10:00:00#)

If you want the expected behavior, please use DiffSeconds/3600 for hours. I should also warn you that DiffMinutes has the same problem, but cuts the DateTime off at seconds.

Best regards,
Ricardo Silva
By the way, the rationale behind this behavior is likely to allow mimicing the behavior of SQL Server's DATEDIFF function, so you get consistent results between your code and queries.