Is there a clean way to compare a timestamp from an external api response against the current day in an Architect data action? i am trying to build a simple logic flow that checks if an order was placed today or yesterday. coming from five9 the date manipulation was a bit different so i am struggling with the cxone expression syntax.
i tried using the DateTimeDiff function first. here is what i put in the expression field:
DateTimeDiff(SystemDateTime(), OrderTimestamp, “days”)
my goal is to check if the result is less than or equal to 1. but when i test this in the data action preview i get an error saying “Invalid argument type for DateTimeDiff”. the OrderTimestamp comes in as a string like “2023-10-25T14:30:00Z”. i thought maybe i need to cast it but i dont know the correct syntax for converting that string to a datetime object inside the expression builder.
then i saw some docs mentioning GetDayOfWeek so i tried this instead:
GetDayOfWeek(OrderTimestamp) == GetDayOfWeek(SystemDateTime())
this actually runs without throwing an error in the preview but the logic feels wrong. if i run this at 11 pm on tuesday and the order was placed at 1 am on tuesday it returns true which is fine. but if i run it at 1 am on wednesday and the order was placed at 11 pm on tuesday it returns false because the day of week changed. i need to know if it was within the last 24 hours not just the same calendar day.
also i noticed that SystemDateTime() returns utc time but our agents are in us/eastern. do i need to do any timezone conversion inside the expression or does the api handle that? i am pretty sure i am missing something basic about how cxone handles date strings in expressions. any help on the correct function to use for a simple “less than 24 hours ago” check would be great. thanks.