Get time as string from DateTime (UTC) inside Xpath

0
In Mendix 9.12.4, is there a function like this that I can use inside an xpath? getTimeFromDateTimeUTC($DateTime) $DateTime represents an UTC date-time. The function returns the string representing the time of $DateTime by using the format "HH:mm:ss".   For example: $DateTime = 2024-06-06 12:00:00 UTC returns '12:00:00'   EDIT 1 I understand formatTimeUTC() function can't be used inside an Xpath.   EDIT 2 If such function doesn't exist, do I have to implement it by a Java Action?   EDIT 3 This edit is a reply to the Micha answer: Hi Micha, The function hours-from-dateTime ( attribute [, timezone ] ) would be OK if it allowed me to set timezone = UTC. But timezone parameter is only available in Mendix >= 9.22.0: https://docs.mendix.com/refguide9/xpath-hours-from-datetime/ I'm using 9.12.4, and so I can't use this parameter. I'm explaining you what I have to do:   - CONTEXT - I have an object Objet. Object has the DateTime attribute time1. I have 3 rows of Object:   UTC time / sessione time 1) 2023-01-01 00:00:00 / 2023-01-01 00:00:00+0000 // NO daylight saving time 2) 2023-04-01 00:00:00 / 2023-04-01 01:00:00+0100 // YES daylight saving time 3) 2023-04-01 23:00:00 / 2023-04-02 00:00:00+0100 // YES daylight saving time This is because my session time refers to 'Europe/London' time-zone.   - TASK - Retrieve rows where time1 = 23:00:00 UTC. In my example only row 3).   - SOLUTION 1 - hours-from-dateTime(time1,'UTC') = 23 It should work correctly, but I can't use timezone parameter in Mendix 9.12.4   - SOLUTION 2 - hours-from-dateTime(time1) = 23 It doesn't work, my local time zone is 'Europe/London'. So 23 is interpreted like 22 UTC.   - SOLUTION 3 - hours-from-dateTime(time1) = 0. It selects row 3) but also 1), and 1) should not be selected. This happens because session time for them is 00:00:00.   - QUESTION - How can I select only row 3)?        
asked
1 answers
0

Hi Claudio, you cannot return it as a string, but you could use an Xpath Contraint Function to return an integer, like [hours-from-dateTime(DateAttribute) = 8] which would return the objects where the time was between 8:00:00 and 8:59:59. Maybe you can work with that?

If you are working with and Xpath eg as a ListView constraint , you could use a data source microflow, which allows you to convert date to string or the other way around in a variable and use the variable in your xpath.

answered