I’ve been trying to build a logic branch in Architect that triggers a specific workflow if an interaction has been waiting for more than 4 hours within the same calendar day. I assumed DateTimeDiff would handle this straightforwardly, but the results are inconsistent.
Here’s the expression I’m using in the Data Action:
DateTimeDiff(Now(), Interaction.QueueEnterTimestamp, 'hours')
The issue seems to be with how the SDK handles the date components when the timestamps fall on the same day versus crossing midnight. When I test this in the sandbox, if QueueEnterTimestamp is 2023-10-27T14:00:00Z and Now() is 2023-10-27T18:00:00Z, the result is correctly 4. However, if I introduce a slight variation in the timezone handling or if the interaction spans a daylight saving change, the diff sometimes returns a negative number or a much larger value than expected, as if it’s counting days instead of hours.
I’ve tried wrapping it in an IF statement to check if GetDayOfWeek(Now()) equals GetDayOfWeek(Interaction.QueueEnterTimestamp), but that doesn’t account for the hour difference properly. The documentation for DateTimeDiff is a bit light on edge cases regarding timezone offsets.
Is there a more reliable way to calculate the hour difference between two timestamps in Architect expressions, or should I be parsing the strings manually using Split and ToInteger? I don’t want to maintain a complex string parser if there’s a cleaner built-in method I’m missing.