r/SentinelOneXDR • u/roarinpenguin • 3h ago
Best Practice Don’t hand-roll epoch math for relative-date filters, check for a built-in function first
Had this come up in an internal workflow-automation channel at S1 this week about Hyperautomation.
Someone needed a filter for agents that hadn’t checked in for 7+ days.
The filter field only takes an absolute timestamp, something like 2018-02-27T04:49:26.257525Z. This is not a relative value, but an actual fixed point in time.
First pass in the thread: pull current time, convert to epoch seconds, subtract 604800, convert the result back into a datetime string, then plug that into the filter. These are four steps for something that’s really just now minus a week.
In Hyperautomation there’s a function for it: DELTA_NOW takes an hour count and hands back now minus that many hours, already formatted as the timestamp the filter wants.
7 days is 168 hours, so the whole thing collapses to one line:lastActiveDate__lt = {{Function.DELTA_NOW(168)}}
No intermediate variable to carry between steps, and it won’t go stale the way a hardcoded date would the next time the workflow runs.
idea how common this specific function is outside our stack, but the pattern seems worth checking before reaching for manual epoch math: is there already a relative-time shortcut built in?
Anyone run into this with other automation tools, or does everyone just end up hand rolling it?
And I'd like to conclude with a pro tip about this function: you can use it with negative numbers too... in a back to the future way.