Running into a weird behavior with date logic in Architect and need a sanity check on the syntax. I’m trying to filter interactions based on whether they happened on a weekend. I’ve got a timestamp coming in from the inbound event, let’s call it @InboundTimestamp.
My first instinct was to use DateTimeDiff. The idea is to compare the inbound timestamp against the current time or a known reference point to see if the difference in days aligns with a weekend pattern. I tried something like this:
DateTimeDiff(@InboundTimestamp, DateTimeNow(), "d")
But this just gives me the absolute number of days between now and the timestamp. If the call came in 3 days ago on a Monday, it returns 3. If it came in 3 days ago on a Saturday, it also returns 3. That doesn’t help me identify the specific day of the week. I’d have to do some modulo math on the total days, but that feels fragile because DateTimeDiff doesn’t seem to preserve the directionality or the specific calendar alignment in a way that maps cleanly to 0-6 for Sunday-Saturday without a known anchor date that is also a Sunday.
So I switched to GetDayOfWeek. The syntax is straightforward:
GetDayOfWeek(@InboundTimestamp)
This returns an integer. The docs say 1 is Sunday and 7 is Saturday, but I’ve seen conflicting info in older forum posts about whether it’s 0-indexed or 1-indexed depending on the region settings of the tenant. I’m in US/Pacific, so assuming standard US locale.
Here is where it gets messy. I want to set a boolean flag @IsWeekend if the day is Saturday or Sunday. My expression looks like this:
IF(OR(Equals(GetDayOfWeek(@InboundTimestamp), 1), Equals(GetDayOfWeek(@InboundTimestamp), 7)), TRUE, FALSE)
This works fine for today’s calls. But when I back-test with historical data from last month, the GetDayOfWeek function seems to be evaluating based on the current system time rather than the timestamp provided? Or maybe I’m misinterpreting the result. I logged the value of GetDayOfWeek for a known Monday timestamp and it returned 1 (Sunday). That can’t be right.
Am I using DateTimeDiff wrong for this use case? Is there a more reliable way to extract the day of the week from a specific timestamp string in Architect without relying on GetDayOfWeek behaving inconsistently? I’ve tried parsing the timestamp string manually using Substring but that’s a nightmare with timezone offsets.