Inferensys

Prompt

Relative Date Expression Resolution Prompt

A practical prompt playbook for resolving relative date expressions like 'next Friday', 'end of month', or '2 weeks ago' into absolute dates in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job, ideal user, and constraints for resolving relative date expressions into absolute dates.

This prompt is designed for scheduling system builders, log processors, and data pipeline engineers who need to convert natural language relative date expressions—such as 'next Friday', 'end of month', or '2 weeks ago'—into absolute, machine-readable dates. The core job-to-be-done is to take a user-provided or system-extracted relative expression and an anchor timestamp, then produce a resolved date, the interpretation rule applied, and a confidence indicator. This is a critical normalization step before temporal data enters databases, reporting pipelines, or scheduling engines where ambiguity breaks downstream queries and comparisons.

Use this prompt when your application accepts flexible date input from users, parses temporal expressions from unstructured text, or needs to resolve relative deadlines in workflow automation. The required inputs are a relative date expression string and an anchor timestamp (defaulting to the current time if not provided). The expected output is a structured object containing the resolved ISO 8601 date, the anchor used, the interpretation rule applied, and a confidence score. Do not use this prompt for simple timestamp format conversion (use the ISO 8601 Normalization prompt instead), for disambiguating MM/DD vs DD/MM formats (use the Ambiguous Date Disambiguation prompt), or for extracting dates from free-text documents (use the Timestamp Extraction prompt). This prompt is specifically for the resolution step where the expression is already isolated and needs to be converted.

The primary risks in production are ambiguity in expressions like 'next Friday' when the anchor is already a Friday, month-boundary edge cases for expressions like 'end of month' or 'last day of February', and locale-specific interpretations of 'next' vs 'this'. Your implementation must include a validation layer that checks the resolved date against the anchor for logical consistency (e.g., 'next Friday' must be in the future relative to the anchor). For high-stakes scheduling or billing systems, require human review when the confidence score falls below a defined threshold. Before deploying, test against a golden dataset of expression-anchor pairs with known resolutions, paying special attention to DST transitions, leap years, and month boundaries.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Relative Date Expression Resolution Prompt works, where it fails, and what you must provide before using it in production.

01

Good Fit: Scheduling and Booking Systems

Use when: converting user-facing relative date expressions like 'next Friday' or 'end of month' into absolute dates for calendar APIs, booking engines, or scheduling UIs. Guardrail: always anchor to a known server timestamp; never rely on the model's assumed 'current date' without explicit injection.

02

Good Fit: Log and Report Date Normalization

Use when: processing human-written log notes, report summaries, or support tickets that contain relative temporal references ('2 weeks ago', 'last quarter'). Guardrail: pair this prompt with a timestamp extraction step first; resolve only expressions that have been explicitly extracted with their surrounding context.

03

Bad Fit: Real-Time Streaming Without Anchor Injection

Avoid when: the system cannot reliably inject an anchor timestamp per request. Relative resolution drifts unpredictably if the model uses its training cutoff or an assumed date. Guardrail: if anchor injection is impossible, fall back to rejecting relative expressions and requiring absolute dates from the user.

04

Bad Fit: Legal or Compliance Deadlines

Avoid when: the resolved date carries legal consequence—filing deadlines, statutory periods, or contractual notice intervals. Ambiguity in 'end of month' or 'within 30 days' can change legal meaning. Guardrail: route these to a human reviewer with the interpretation rule shown; never auto-commit resolved dates to systems of record.

05

Required Input: Explicit Anchor Timestamp

Risk: without an explicit anchor timestamp, the model may resolve 'next Friday' relative to an incorrect or inconsistent reference point. Guardrail: always pass a [ANCHOR_TIMESTAMP] in ISO 8601 format as part of the prompt. Log the anchor alongside the resolved output for auditability.

06

Operational Risk: Holiday and Business-Day Ambiguity

Risk: expressions like 'next business day' or 'before the holiday' require a holiday calendar that the model does not have by default. Resolution will be wrong for region-specific or company-specific holidays. Guardrail: inject a [HOLIDAY_CALENDAR] or [BUSINESS_DAY_RULE] parameter when business-day logic matters; otherwise, flag the output as calendar-unaware.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for resolving relative date expressions into absolute dates with interpretation rules.

This prompt template converts natural-language relative date expressions like 'next Friday', 'end of month', or '2 weeks ago' into absolute dates. It requires an anchor timestamp to serve as the reference point for resolution, and it returns not only the resolved date but also the interpretation rule applied—making the resolution auditable and debuggable. Use this template when your scheduling system, log processor, or reporting pipeline receives human-entered date expressions that must be normalized before downstream queries or comparisons.

text
You are a temporal expression resolver. Your job is to convert relative date expressions into absolute dates given an anchor timestamp.

[INPUT]
Relative date expression: [RELATIVE_EXPRESSION]
Anchor timestamp (ISO 8601): [ANCHOR_TIMESTAMP]
Timezone context: [TIMEZONE]

[CONSTRAINTS]
1. Resolve the expression relative to the anchor timestamp in the given timezone.
2. Return the resolved date in ISO 8601 format (YYYY-MM-DD).
3. Explain the interpretation rule you applied in plain language.
4. If the expression is ambiguous, list the possible interpretations and explain which one you chose and why.
5. If the expression cannot be resolved, return an error with the reason.
6. Do not invent dates beyond what the expression and anchor support.

[OUTPUT_SCHEMA]
{
  "resolved_date": "YYYY-MM-DD",
  "anchor_used": "[ANCHOR_TIMESTAMP]",
  "interpretation_rule": "string explaining the rule applied",
  "ambiguities": ["string describing each ambiguity if any"],
  "confidence": "high|medium|low",
  "error": null or "error message if unresolvable"
}

[EXAMPLES]
Expression: "next Friday"
Anchor: "2025-03-10T14:00:00-04:00" (Monday)
Output: {"resolved_date": "2025-03-14", "anchor_used": "2025-03-10T14:00:00-04:00", "interpretation_rule": "'Next Friday' from Monday March 10 resolves to the upcoming Friday March 14 in the same week.", "ambiguities": [], "confidence": "high", "error": null}

Expression: "end of month"
Anchor: "2025-01-15T09:00:00Z"
Output: {"resolved_date": "2025-01-31", "anchor_used": "2025-01-15T09:00:00Z", "interpretation_rule": "'End of month' from January 15 resolves to January 31, the last calendar day of the current month.", "ambiguities": [], "confidence": "high", "error": null}

Expression: "2 weeks ago"
Anchor: "2025-04-20T12:00:00+00:00"
Output: {"resolved_date": "2025-04-06", "anchor_used": "2025-04-20T12:00:00+00:00", "interpretation_rule": "'2 weeks ago' from April 20 subtracts 14 calendar days, landing on April 6.", "ambiguities": [], "confidence": "high", "error": null}

Expression: "next month"
Anchor: "2025-01-31T00:00:00Z"
Output: {"resolved_date": "2025-02-28", "anchor_used": "2025-01-31T00:00:00Z", "interpretation_rule": "'Next month' from January 31 resolves to February 28, the last day of the following month, since February does not have 31 days.", "ambiguities": ["'Next month' could mean February 28 (same day-of-month clamped) or March 3 (adding 31 days). Chose calendar-month interpretation."], "confidence": "medium", "error": null}

Adapt this template by replacing the placeholders with your application's actual values. The [RELATIVE_EXPRESSION] comes from user input or upstream systems. The [ANCHOR_TIMESTAMP] should be the current time or a relevant reference point from your system. The [TIMEZONE] field is critical for expressions like 'tomorrow' or 'next business day' where the date boundary depends on the local timezone. For production use, wrap this prompt in a validation layer that checks the output schema, verifies the resolved date is within expected bounds, and logs any low-confidence or ambiguous resolutions for human review. Test this prompt against month-boundary edge cases, leap years, DST transitions, and locale-specific expressions like 'fortnight' or 'biweekly' before deployment.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Relative Date Expression Resolution Prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to check the input before execution.

PlaceholderPurposeExampleValidation Notes

[RELATIVE_EXPRESSION]

The natural language relative date expression to resolve

next Friday

Non-empty string; length < 200 chars; must contain at least one temporal keyword (next, last, ago, end of, beginning of, etc.)

[ANCHOR_TIMESTAMP]

The reference point from which the relative expression is calculated

2025-01-15T14:30:00-05:00

Must parse as valid ISO 8601 with timezone offset; reject if timezone is missing or ambiguous; default to system time if null allowed by config

[TARGET_TIMEZONE]

The timezone in which the resolved date should be expressed

America/New_York

Must match IANA timezone database identifier; validate against known timezone list; reject raw UTC offset strings

[HOLIDAY_CALENDAR]

Optional calendar of holidays to consider for business-day-aware expressions

US-NYSE

Null allowed; if provided, must match a supported calendar key in the system; validate against registered calendar list

[RESOLUTION_STRATEGY]

The rule for handling ambiguous expressions like 'end of month' on a 31st

strict

Must be one of: strict, lenient, business-day-adjusted; reject unknown values; default to strict if not provided

[OUTPUT_SCHEMA]

The expected JSON structure for the resolved date output

{"resolved_date": "...", "anchor_used": "...", "rule_applied": "..."}

Must be a valid JSON Schema or example object; validate parseability before prompt assembly; reject if schema contains circular references

[MAX_RESOLUTION_DAYS]

The maximum number of days forward or backward the resolver is allowed to compute

365

Must be a positive integer; reject values > 730 to prevent runaway date computation; null allowed if no boundary enforcement needed

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Relative Date Expression Resolution Prompt into a scheduling system, log processor, or reporting pipeline.

This prompt is designed to be called as a deterministic resolution step within a larger application pipeline, not as a free-form chat interface. The primary integration pattern is a synchronous API call where the application provides the relative expression, an anchor timestamp, and optional context (timezone, holidays, business rules), and expects a structured JSON response containing the resolved absolute date, the interpretation rule applied, and a confidence flag. The prompt should be treated as a stateless function: given the same inputs, it must produce the same resolution. Do not rely on model memory of prior calls.

Input contract: The application must supply [RELATIVE_EXPRESSION] (the string to resolve), [ANCHOR_TIMESTAMP] (an ISO 8601 timestamp representing 'now' or the reference point), [TIMEZONE] (IANA timezone string like America/Chicago), and optionally [HOLIDAY_CALENDAR] (a list of non-business days) and [BUSINESS_RULES] (e.g., 'next business day means next weekday that is not a holiday'). Output contract: The model must return a JSON object with resolved_date (ISO 8601 date string), anchor_used (the anchor timestamp provided), interpretation (a human-readable explanation of the rule applied), and confidence (a value of high, medium, or low). Validation layer: Before the resolved date enters any downstream system (booking engine, report query, audit log), the application must validate that resolved_date is a parseable date, that confidence is not low without explicit handling, and that the date falls within an acceptable operational window (e.g., not more than 1 year in the past or 5 years in the future unless the use case permits it).

Retry and fallback logic: If the model returns malformed JSON, a missing resolved_date, or a confidence of low, the application should retry once with a simplified version of the prompt that removes optional context and asks for only the most likely resolution. If the retry also fails or returns low confidence, the system should escalate to a human review queue rather than silently defaulting to a potentially incorrect date. For high-throughput pipelines where human review is impractical, implement a safe default (e.g., treat 'next Friday' as the upcoming Friday from the anchor date using a deterministic library like dateutil or moment-business-days) and log the mismatch for later analysis. Model choice: This task benefits from models with strong reasoning and instruction-following, such as Claude 3.5 Sonnet or GPT-4o. Avoid smaller or older models that may hallucinate date arithmetic. Observability: Log every resolution with the input expression, anchor, resolved date, confidence, and model version. This audit trail is critical for debugging scheduling errors and for compliance in regulated environments where date calculations affect deadlines, billing, or legal obligations.

Tool use and RAG considerations: For most implementations, this prompt does not require external tools or retrieval. The model can perform the date arithmetic internally. However, if your [HOLIDAY_CALENDAR] is large or changes frequently, consider injecting it via a retrieval step before the prompt call rather than hardcoding it. For recurring resolution needs (e.g., resolving 'next business day' for thousands of records), batch the calls and consider caching results for identical expression-anchor pairs to reduce latency and cost. What to avoid: Do not use this prompt for resolving dates in user-facing chat without first validating the output. Do not pass the resolved date directly into financial transactions, legal deadlines, or medical scheduling without human confirmation when confidence is anything other than high. The prompt resolves linguistic ambiguity, but the application owns the business risk.

PRACTICAL GUARDRAILS

Common Failure Modes

Relative date resolution fails in predictable ways. These are the most common production failure modes and how to guard against them before they corrupt downstream schedules, reports, or logs.

01

Missing or Ambiguous Anchor Timestamp

What to watch: The model resolves 'next Friday' relative to an assumed 'now' that may be wrong—wrong timezone, wrong server clock, or wrong reference date from the user's context. Guardrail: Always inject an explicit [ANCHOR_TIMESTAMP] in ISO 8601 with timezone. Never rely on the model's internal sense of 'today.' Validate that the resolved date is not before the anchor when the expression implies future.

02

Month-Boundary Overflow

What to watch: Expressions like 'end of month + 1 day' or 'next month' on January 31st produce impossible dates (February 31st) or silently roll over to March. Guardrail: Add a post-resolution validation step that checks the resolved date's month and day against the expected target. For month-relative math, compute boundaries first, then apply offsets. Test explicitly with January 29–31 inputs.

03

Locale-Week Misalignment

What to watch: 'Next week' or 'last Monday' depends on locale-specific week-start conventions (Sunday vs Monday). The model may default to a US-centric interpretation even when the user's locale differs. Guardrail: Inject a [WEEK_START_DAY] parameter (e.g., 'Monday') into the prompt. Include a locale context field. Test with cross-locale cases where the same expression should resolve to different dates.

04

Holiday-Aware Resolution Without a Holiday Calendar

What to watch: 'Next business day' or 'before the holiday' requires a holiday calendar that the model does not have reliably. The model may hallucinate holiday dates or apply US federal holidays to a non-US context. Guardrail: Provide a [HOLIDAY_CALENDAR] as structured data (date + name + region). If no calendar is available, flag the output with requires_human_review: true and do not resolve business-day logic.

05

Vague Expression Over-Confidence

What to watch: Expressions like 'soon,' 'later this month,' or 'early next quarter' have no single correct resolution, but the model may pick a specific date without indicating uncertainty. Guardrail: Require the output schema to include a confidence field (0–1) and an interpretation_rule field explaining the resolution logic. Set a threshold below which the output is flagged for human review rather than silently ingested.

06

DST Transition Ambiguity

What to watch: Resolving '2:30 AM' on a DST transition day can map to two different UTC timestamps or a nonexistent local time. The model rarely flags this. Guardrail: When the anchor or resolved date falls on a known DST transition day for the given timezone, add a dst_ambiguous: true flag to the output. Require the caller to specify a DST disambiguation policy (prefer standard, prefer daylight, or reject).

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Relative Date Expression Resolution Prompt before shipping. Each criterion targets a known failure mode in temporal resolution workflows.

CriterionPass StandardFailure SignalTest Method

Anchor timestamp grounding

Output includes the exact [ANCHOR_TIMESTAMP] used for resolution

Missing anchor field or anchor differs from input without explanation

Parse output JSON; assert anchor_timestamp field matches input exactly

Absolute date resolution

Resolved date is a valid ISO 8601 date string matching the correct calendar date for the expression

Date off by one day, wrong month, or wrong year relative to anchor

Run against golden set of 20 expression-anchor pairs with known correct dates; require 100% match

Interpretation rule transparency

Output includes a human-readable interpretation_rule field explaining how the expression was resolved

Rule field missing, generic, or contradicts the resolved date

Spot-check 10 outputs; verify rule text matches resolution logic for expressions like 'next Friday' vs 'this Friday'

Month boundary handling

Expressions like 'end of month' or 'last day of March' resolve correctly across months with 28, 29, 30, and 31 days

February resolves to 28th or 29th incorrectly; 31st assigned to 30-day month

Test with anchors in January, February (leap and non-leap), April; verify correct last-day values

Week boundary handling

Expressions like 'next Monday' resolve correctly when anchor is before, on, or after Monday

Next weekday resolves to same week when anchor is after that day; 'this' vs 'next' confusion

Test anchors on Sunday, Monday, Tuesday; verify 'next Monday' always resolves to the following week's Monday

Holiday-aware resolution

When [HOLIDAY_CALENDAR] is provided, expressions like 'next business day' skip holidays and weekends

Holiday treated as business day; resolution lands on a date in the holiday list

Provide a holiday calendar with known dates; test 'next business day' from the day before a holiday; assert output is the day after the holiday

Ambiguous expression handling

Output includes a confidence_score field; ambiguous expressions score below 0.9 and include an ambiguity_note

Ambiguous expressions like 'next week' resolved without noting ambiguity; confidence always 1.0

Test with 'next week', 'later this month', 'soon'; assert confidence_score < 0.9 and ambiguity_note is non-empty

Invalid input rejection

Nonsense expressions like 'the day after never' return an error object with valid=false and an error_reason

Invalid input produces a hallucinated date or crashes the parser

Send 5 invalid expressions; assert valid=false in output and error_reason is present and descriptive

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single anchor timestamp. Remove the holiday-aware and business-rule layers. Accept a simple JSON object with expression, anchor_timestamp, and timezone fields. Return only resolved_date, interpretation_rule, and confidence.

code
Resolve this relative date expression to an absolute ISO 8601 date.

Expression: [EXPRESSION]
Anchor timestamp: [ANCHOR_TIMESTAMP]
Timezone: [TIMEZONE]

Return JSON with: resolved_date, interpretation_rule, confidence (0-1).

Watch for

  • Month-boundary expressions like 'end of month' resolving incorrectly when the anchor is already the last day
  • 'Next Friday' ambiguity when the anchor is Friday itself
  • Missing timezone causing off-by-one-day errors near midnight
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.