TL;DR: If your agent needs to react to dates like âoverdue,â âdue within 3 days,â or âopened more than 14 days ago,â donât ask it to calculate from date strings in the prompt. Thatâs unreliable. Instead, create a Formula custom field such as Due Date - Today, set the format to Number, and let the agent compare the resulting integer. This gives you much more reliable date-based behavior.
Hello Community! đ
Hereâs a practical pattern for anyone building AI Agents that need to work with deadlines, aging work, or SLA timing.
Sooner or later, most agents need to make decisions based on time:
- âIf overdue, escalateâ
- âIf opened more than 14 days ago, summarize the threadâ
- âIf due within 3 days, add a watcherâ
The natural first move is to put the math in the prompt and ask the agent something like:
> âIs the due date within 3 days?â
In practice, that tends to be flaky. It may work sometimes, fail other times, and can quietly drift over time.
Why?
Because language models read `2026-04-28` as text, not as a number. Reasoning over text-based dates is brittle.
Thereâs a much cleaner fix
The pattern
Pre-compute the value on the item, and let the agent read the result. A custom field of type Formula, with Due Date - Today and the format set to Number, gives the agent a single integer it can compare against on every item. The agent never has to know what today's date is.
How to set it up
- Add column on a folder, project, or space view.
- Write the column name - I'd suggest Hours to Due Date. (See "How to read the number" below for why "Hours" is more accurate than "Days".)
- + Custom Field.
- Type: Formula.
- In the Formula field, select Due Date.
- Type -.
- In the Formula field, select Today.
- In the Format field, select Number.
Important note on Step 8
This is the one to slow down on. The Format field decides what the agent reads. "Number" gives a single integer. Any other format renders the same underlying value as text (date string, duration phrase) and the reliability evaporates.
How to read the number
The result is in working hours - not calendar hours, and not days.
Wrikeâs Today function respects each userâs working schedule, so the count excludes:
- Evenings
- Weekends
- Configured holidays
Assuming an 8-hour workday:
Value | Meaning |
|---|
+8 | 1 working day until due |
+40 | 1 working week until due |
+680 | ~85 working days, ~17 working weeks until due |
-56 | 7 working days past the due date |
- Plus is good = buffer remaining Â
- Minus is bad = overdue
Sign convention
You could also build the formula as:
Today - Due Date
But then positive numbers mean overdue, which is harder for humans to scan quickly.
So unless you have a strong reason otherwise, stick with:
Due Date - Today
Using it in the agent prompt
Once the field exists, your prompt becomes a simple number comparison.
Examples:
- âIf Hours to Due Date is less than 24, add Marco as a watcher and post a comment that the item is at risk of breaching SLA.â
- âIf Hours to Due Date is between -8 and 0 (just slipped past due in the last working day), summarize the latest comments and assign to the team lead.â
- Â âIf Hours to Due Date is greater than 80 (about 10 working days out), do nothing.â
This is much more reliable because the agent is comparing integers, not interpreting dates.
Variations from the field
Three real setups using the same primitive:
- Days since created - Today - Created Date, format Number. Aging out stale work: "if it hasn't moved in 14 working days, route to the team lead."
- SLA countdown - SLA Deadline - Today against a custom date field. Escalate before the deadline lands, not after.
- Time on current status - Today - Status Last Changed. Catches the "stuck in review" pattern.
Any "how long since / how long until X" question becomes a Number field the agent can read.
What the agent sees vs. what you see
If your column displays as a duration ("2d 5h") in the UI, that's a display preference - the agent still reads the underlying Number. To check the raw value, hover the cell in a list view; Wrike shows the integer in the tooltip.
We hope this tip helps you make your AI Agents more reliable when working with deadlines, SLAs, and aging tasks. If youâre using similar formula-based setups in your workflows, weâd love to hear how youâre applying them đ