Just a double check before I do a bug report I have an attribute with a non localized date time. The UTC date time is 14-08-2020 23:00. Double checked this in the database that indeed the time is 2300 hours. Now I do an XPath retrieve [hours-from-dateTime(DateTimeAttribute) = 23] I would expect that it would find the record with 14-08-2020 23:00. But to retrieve that record I have to use the XPath [hours-from-dateTime(DateTimeAttribute) = 21] and thus take into account the session time which is currently two hours of from UTC. In my opinion this is not correct and this must be a bug in my opinion. Or is my thinking not correct? Regards, Ronald Mendix accepted this as a bug (ticket (105685)) [UPDATE 30-9-2020] It was indeed a bug that has been fixed in Mx8.14. [Update 17-5-2021] Bug is back in Mx8.18.4. (ticket 122231 )
Reading your case description and reading https://docs.mendix.com/refguide/xpath-hours-from-datetime, it seems wrong indeed. There is no mention of any timezone in any of the documentation nor are there ~UTC-variants of the functions. This function is probably not heavily used and only tested on dates with localized set to Yes, which is the default and the most common occurrence.
A solution would be either add a timezone-parameter or to duplicate the function to ~UTC and ~Local. The ~local variant of course needs to know the timezone, either by determining it or by get told via a parameter.
Btw. This goes for each of the DateTime related Xpath constraints.
I think you can safely file a bug report.
Tim van Steenbergen
I think it works as designed. (not saying that the design is good though ;-) )
Non-localized has only effect in the browser representation. On the application server the time zone of the user, project or server is used. and thus an hour offset to UTC is logical.