Architect DateTimeDiff expression returning null in Data Action mapping

Getting a null result from the DateTimeDiff function in an Architect Data Action mapping. The goal is to filter out messages older than 24 hours before sending them to our Android app via webhook.

The expression looks like this:
DateTimeDiff("now", "${system.messageReceivedTimestamp}", "hours")

When I test this in the Architect simulator, it returns null instead of the expected integer. I’ve verified that system.messageReceivedTimestamp contains a valid ISO 8601 string like 2023-10-27T14:30:00Z. The docs say DateTimeDiff handles ISO strings, but it seems to choke on the timezone suffix or the format. I tried stripping the Z and appending -05:00 for Chicago time, but that just breaks the parser entirely with a syntax error.

I also tried using GetDayOfWeek to see if date parsing works at all, and that returns 1 correctly for a Monday. So the timestamp itself is being read, but the diff function fails. Is there a specific format required for the input strings in DateTimeDiff? Or is there a known bug with the hours unit parameter? The JSON payload from the trigger looks clean, so I don’t think it’s a data issue.

The issue is the format of system.messageReceivedTimestamp. DateTimeDiff in Architect expects ISO 8601 strings or specific date objects, but that system variable often comes through as a Unix epoch or a localized string depending on your region settings. Passing a non-standard string to the function returns null because the parser can’t coerce it.

Try parsing it explicitly before the diff. Here’s the corrected expression chain:

DateTimeDiff(
 "now", 
 formatDateTime(parseDateTime("${system.messageReceivedTimestamp}", "ISO8601"), "ISO8601"), 
 "hours"
)

If parseDateTime still chokes, the input is likely an integer epoch. In that case, you need to convert it first:

DateTimeDiff(
 "now", 
 fromEpoch("${system.messageReceivedTimestamp}"), 
 "hours"
)

I usually wrap this in a if check to handle nulls gracefully so the flow doesn’t break on malformed data:

if(
 isEmpty("${system.messageReceivedTimestamp}"), 
 0, 
 DateTimeDiff("now", fromEpoch("${system.messageReceivedTimestamp}"), "hours")
)

Also, make sure your Data Action mapping target is set to Integer or Number. If it’s set to String, Architect might try to cast the result back to text, which can cause downstream issues in your webhook payload. The fromEpoch function is your best bet here since messageReceivedTimestamp is almost always a Unix timestamp in the internal system variables. Check the raw JSON in the simulator debug view to confirm the type. If it’s a string like "2023-10-27T10:00:00Z", stick with the parseDateTime approach. If it’s 1698400800000, use fromEpoch. Don’t guess the format.