This prompt is for RAG system operators and search engineers who need to convert relative, ambiguous, or colloquial time expressions in user queries into explicit, machine-readable date ranges for metadata filtering. The core job-to-be-done is preventing retrieval failures caused by queries like 'last quarter's reports' or 'next Monday's schedule' hitting a vector index that only understands ISO 8601 date constraints. The ideal user is a developer building a production retrieval pipeline over a time-sensitive corpus—such as financial filings, internal communications, or event logs—where a missed date boundary means retrieving irrelevant or empty results.
Prompt
Date and Time Expression Normalization Prompt Template

When to Use This Prompt
Define the job, ideal user, required context, and constraints for the Date and Time Expression Normalization prompt.
Use this prompt when your retrieval system supports structured metadata filters on date fields and your users express time constraints in natural language. It is designed to sit in the pre-retrieval query processing layer, after query validation but before the final search request is assembled. The prompt expects a user query containing a temporal expression, a reference timestamp (typically now in ISO 8601), and an optional timezone. It returns a normalized date range with an explicit start and end in ISO 8601, a confidence flag, and a rationale for boundary decisions. Do not use this prompt for queries that already contain explicit date ranges, for time-series forecasting tasks, or for generating relative time expressions from absolute dates. It is a normalization tool, not a reasoning engine for temporal logic.
Before integrating this prompt into a production pipeline, you must define your timezone handling strategy. Ambiguous expressions like 'end of day' or 'this weekend' resolve differently depending on whether you anchor to UTC, the user's local time, or the data corpus timezone. You should also prepare eval cases for boundary dates: queries issued at midnight, queries spanning daylight saving transitions, and queries with fiscal calendars that differ from calendar months. The prompt includes a confidence flag for a reason—wire it into your pipeline to trigger a human review or a clarification question when confidence is low. If your system cannot tolerate any incorrect date normalization, this prompt alone is insufficient; you will need a human-in-the-loop review step for low-confidence outputs.
Use Case Fit
Where the Date and Time Expression Normalization Prompt works, where it breaks, and what you must provide before using it in a production RAG pipeline.
Good Fit: Relative Time in Enterprise Search
Use when: users query knowledge bases with phrases like 'last quarter,' 'next Monday,' or 'this fiscal year.' The prompt converts these into explicit ISO 8601 date ranges for metadata filtering. Guardrail: always provide the current reference timestamp and timezone as input variables; never rely on the model's internal date knowledge.
Bad Fit: Recurring Event Scheduling
Avoid when: the task involves generating cron expressions, calculating recurring meeting patterns, or resolving complex holiday calendars. This prompt normalizes a single temporal expression into a bounded range, not an infinite recurrence rule. Guardrail: route scheduling and recurrence tasks to a dedicated temporal logic library or a separate agent with recurrence-aware tooling.
Required Inputs: Reference Clock and Timezone
What to watch: the prompt cannot resolve 'now,' 'today,' or 'next week' without an explicit reference timestamp. Ambiguous timezone handling produces off-by-one-day errors at boundary hours. Guardrail: always pass [CURRENT_TIMESTAMP] in ISO 8601 with offset and [USER_TIMEZONE] as IANA timezone strings. Validate that the output date range falls within expected bounds before retrieval.
Operational Risk: Ambiguous Boundary Dates
What to watch: phrases like 'last month' on January 2nd or 'end of quarter' near fiscal boundaries produce inconsistent results across models and runs. The confidence flag may be misleadingly high for inherently ambiguous expressions. Guardrail: add a post-processing validator that checks the output range against a business calendar API. Flag any normalized range where the model's confidence score is below 0.85 for human review before retrieval executes.
Operational Risk: Fiscal vs. Calendar Interpretation
What to watch: 'Q3' means different date ranges depending on whether the organization uses calendar quarters or a shifted fiscal year. The model defaults to calendar interpretation unless explicitly instructed. Guardrail: pass [FISCAL_YEAR_START_MONTH] and [FISCAL_YEAR_START_DAY] as input variables. Add an eval test case for each fiscal boundary to catch regression when the prompt template changes.
Pipeline Integration: Pre-Retrieval Filter Construction
What to watch: the normalized ISO 8601 range must be converted into your vector database's filter syntax before retrieval executes. Direct string interpolation without validation risks injection or malformed filter clauses. Guardrail: parse the prompt output through a structured schema validator, then construct the metadata filter programmatically using your database client library. Never concatenate model output directly into query strings.
Copy-Ready Prompt Template
A reusable prompt that normalizes relative date and time expressions into explicit ISO 8601 date ranges with a confidence flag.
This prompt template converts user-supplied relative time expressions—such as 'last quarter', 'next Monday', or 'the past few weeks'—into explicit, machine-readable ISO 8601 date ranges suitable for metadata filtering in RAG retrieval pipelines. It is designed to be dropped into a pre-retrieval normalization step where ambiguous temporal language would otherwise cause missed results or incorrect time scoping. The template expects a reference timestamp to anchor relative expressions, a target timezone for boundary calculation, and an optional list of business-specific fiscal or holiday calendars that override default calendar boundaries.
textYou are a date and time normalization engine for a retrieval system. Your job is to convert relative or ambiguous date expressions into explicit ISO 8601 date ranges. ## INPUT User query: [USER_QUERY] Reference timestamp (ISO 8601): [REFERENCE_TIMESTAMP] Target timezone (IANA format): [TARGET_TIMEZONE] Fiscal calendar overrides (JSON, optional): [FISCAL_CALENDAR_OVERRIDES] ## OUTPUT SCHEMA Return a JSON object with the following fields: { "original_expression": "string (the extracted date expression from the query)", "start_date": "string (ISO 8601 date or datetime, inclusive start of range)", "end_date": "string (ISO 8601 date or datetime, inclusive end of range)", "confidence": "number (0.0 to 1.0, how certain the normalization is)", "ambiguity_flag": "boolean (true if the expression could map to multiple ranges)", "alternative_ranges": ["array of {start_date, end_date, interpretation} objects if ambiguous"], "reasoning": "string (brief explanation of how the range was derived)" } ## CONSTRAINTS - Use the reference timestamp as 'now' for all relative calculations. - Apply the target timezone for day-boundary calculations. 'Today' starts at 00:00:00 in that timezone. - If fiscal calendar overrides are provided, use them for 'quarter', 'fiscal year', and similar expressions. Otherwise use standard calendar quarters (Q1: Jan-Mar, Q2: Apr-Jun, Q3: Jul-Sep, Q4: Oct-Dec). - For 'last X' expressions (last week, last month, last year), return the immediately preceding complete period, not the current partial period. - For 'next X' expressions, return the immediately following complete period. - For 'past N days/weeks/months', calculate the range from (reference - N units) to reference timestamp. - If the expression is already an explicit date range, extract and normalize it without reinterpretation. - If no date expression is found, return null for start_date and end_date with confidence 0.0. - Flag ambiguous expressions (e.g., 'this Friday' when reference is Friday) and include alternative interpretations. ## EXAMPLES Input: "sales report for last quarter" | Reference: 2025-07-15T10:00:00Z | Timezone: America/New_York Output: {"original_expression": "last quarter", "start_date": "2025-04-01", "end_date": "2025-06-30", "confidence": 0.98, "ambiguity_flag": false, "alternative_ranges": [], "reasoning": "Standard calendar Q2 2025 is the quarter immediately preceding the reference date of July 2025."} Input: "meetings from the past 2 weeks" | Reference: 2025-07-15T10:00:00Z | Timezone: America/Chicago Output: {"original_expression": "past 2 weeks", "start_date": "2025-07-01", "end_date": "2025-07-15", "confidence": 0.95, "ambiguity_flag": false, "alternative_ranges": [], "reasoning": "14-day lookback from reference date, inclusive of both boundaries."} Input: "data from this Friday" | Reference: 2025-07-18T09:00:00Z (Friday) | Timezone: Europe/London Output: {"original_expression": "this Friday", "start_date": "2025-07-18", "end_date": "2025-07-18", "confidence": 0.70, "ambiguity_flag": true, "alternative_ranges": [{"start_date": "2025-07-25", "end_date": "2025-07-25", "interpretation": "next Friday"}], "reasoning": "Reference date is already Friday. 'This Friday' could mean today or next Friday. Flagged for disambiguation."} ## INSTRUCTIONS 1. Extract the date or time expression from the user query. 2. Resolve it against the reference timestamp and timezone. 3. Apply any fiscal calendar overrides if provided. 4. Produce the output JSON conforming to the schema above. 5. If the expression is ambiguous, set ambiguity_flag to true and include alternative interpretations.
To adapt this template for your own RAG pipeline, replace the square-bracket placeholders with values from your application context. The [USER_QUERY] should be the raw user input before any other preprocessing. The [REFERENCE_TIMESTAMP] should typically be the current server time in ISO 8601 format, though you may substitute a fixed reference for replay or testing. The [TARGET_TIMEZONE] must be an IANA timezone string such as America/Chicago or Asia/Tokyo—do not use UTC offsets alone, as they do not encode daylight saving rules. The optional [FISCAL_CALENDAR_OVERRIDES] field accepts a JSON object mapping fiscal period names to {start_month, start_day} objects, for example {"Q1": {"start_month": 2, "start_day": 1}} for a February-start fiscal year. If your application does not use fiscal calendars, omit this field or pass an empty object. Before deploying, validate the output against your downstream metadata filter schema to ensure the date formats match what your search index expects.
Prompt Variables
Required inputs for the Date and Time Expression Normalization prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to programmatically verify the input before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_QUERY] | The raw natural language query containing a relative or ambiguous time expression to normalize | What were our sales last quarter? | Must be a non-empty string. Check length > 0 and not only whitespace. Reject null or undefined before prompt assembly. |
[REFERENCE_TIMESTAMP] | The current moment used as the anchor for resolving relative expressions like 'today', 'next week', or 'last month' | 2025-03-15T14:30:00-04:00 | Must be a valid ISO 8601 datetime string with timezone offset. Parse with Date.parse() or equivalent. Reject if timezone is missing or offset is ambiguous. |
[TIMEZONE] | IANA timezone identifier for the user or system context, used to resolve day boundaries and business calendar references | America/New_York | Must match a valid IANA timezone from a maintained list. Validate against Intl.supportedValuesOf('timeZone') or a timezone database. Reject free-text timezone names. |
[OUTPUT_SCHEMA] | The exact JSON schema the model must conform to, defining fields for start_date, end_date, confidence, and normalization notes | {"type": "object", "properties": {"start_date": {"type": "string"}, "end_date": {"type": "string"}, "confidence": {"type": "number"}, "normalization_notes": {"type": "string"}}, "required": ["start_date", "end_date", "confidence"]} | Must be a valid JSON Schema object. Validate with a JSON Schema validator before injection. Ensure required fields match downstream parser expectations. Reject schemas missing required date fields. |
[FISCAL_CALENDAR_START] | The month and day that defines the start of the fiscal year, required when queries reference fiscal periods like 'Q3 FY2025' | 07-01 | Must be in MM-DD format. Validate month between 01 and 12, day between 01 and 31. Set to null if fiscal calendar alignment is not needed for the query domain. |
[BUSINESS_DAYS_ONLY] | Boolean flag indicating whether date range calculations should exclude weekends and holidays when resolving expressions like '5 business days from now' | Must be true or false. Default to false if not specified. Validate type is boolean, not string. Controls whether the prompt instructs the model to skip non-business days in range computation. | |
[AMBIGUITY_THRESHOLD] | Confidence score below which the model should flag the normalization as ambiguous and request clarification instead of guessing | 0.85 | Must be a float between 0.0 and 1.0. Validate range. Used to gate whether the output includes a clarification_request field. Lower values produce more aggressive normalization with higher error risk. |
[HOLIDAY_CALENDAR] | Optional list of holiday dates to exclude when computing business-day-aware ranges, specific to the user's region or organization | ["2025-01-01", "2025-12-25"] | Must be an array of ISO 8601 date strings or null. Validate each entry is a valid date. If null, the model uses only weekend exclusion. Provide for enterprise deployments with custom holiday schedules. |
Implementation Harness Notes
How to wire the Date and Time Expression Normalization prompt into a production RAG pipeline with validation, retries, and safe defaults.
Integrating this prompt into a production system means treating it as a deterministic pre-retrieval filter, not a conversational assistant. The prompt expects a raw user query string and a reference timestamp (the user's 'now') as input. It must return a structured JSON object containing ISO 8601 date ranges, a resolved reference point, and a confidence flag. The application layer should never pass the raw user query directly to the retrieval engine if the normalization step succeeds and returns a high-confidence result. Instead, the application should use the resolved date ranges to construct explicit metadata filters (e.g., start_date >= [RESOLVED_START] AND end_date <= [RESOLVED_END]) that are appended to the retrieval query's filter clause. This keeps the semantic search vector or keyword query clean while offloading temporal precision to the database's indexed date fields.
The implementation harness must handle several failure modes gracefully. First, if the model returns a confidence score below your defined threshold (e.g., < 0.9), the system should either discard the temporal filter and retrieve broadly, or escalate to a human-in-the-loop review queue if the domain is high-stakes (e.g., financial audits, clinical records). Second, the application must validate the output schema strictly: check that resolved_start and resolved_end are valid ISO 8601 strings, that resolved_start is before resolved_end, and that the reference_timestamp matches the input. A retry loop with a maximum of two attempts can recover from malformed JSON, but persistent schema violations should trigger a fallback to a safe default (e.g., the last 90 days) and log the failure for prompt debugging. Third, timezone handling is a common source of silent errors. The harness should always pass an explicit UTC offset or IANA timezone string in the reference_timestamp field (e.g., 2025-03-15T10:30:00-04:00) and verify that the resolved output uses the same offset or converts it correctly.
For observability, log the original query, the resolved date range, the confidence score, and the model's raw output before any post-processing. This audit trail is essential for debugging retrieval failures where a user asks for 'last month's reports' but sees results from the wrong period. In high-compliance environments, this log becomes part of the retrieval decision record. When wiring this into a RAG orchestrator like LangChain or a custom FastAPI middleware, place the normalization step after PII redaction and spelling correction but before query embedding and vector search. Avoid the temptation to pass the normalized date expression back into the user-facing query string; keep it as a parallel structured filter to prevent confusing the semantic search with date literals. Finally, test the harness end-to-end with eval cases that include ambiguous boundaries ('end of last quarter' when the query arrives on the first day of the new quarter), relative expressions without a clear anchor ('recently'), and timezone edge cases to ensure the system degrades safely rather than silently retrieving the wrong data.
Expected Output Contract
Defines the structure, types, and validation rules for the normalized date/time output. Use this contract to build a post-processing validator before the date range is passed to a metadata filter or retrieval system.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
normalized_start_date | ISO 8601 date string (YYYY-MM-DD) | Parse check: must be a valid date. Must be <= normalized_end_date. Reject if the model hallucinates a date not grounded in [CURRENT_DATE]. | |
normalized_end_date | ISO 8601 date string (YYYY-MM-DD) | Parse check: must be a valid date. Must be >= normalized_start_date. For single-day expressions, start and end must be equal. | |
original_expression | string | Must exactly match the extracted time expression substring from [USER_QUERY]. If no expression is found, this must be null. | |
resolution_notes | string | Must contain a brief explanation of the boundary logic (e.g., 'last quarter resolved to previous full calendar quarter'). Required for auditability. | |
confidence_score | float (0.0 to 1.0) | Must be a number between 0.0 and 1.0. If the expression is ambiguous (e.g., 'next Monday' on a Sunday), the score must be < 0.95. | |
timezone | string (IANA format, e.g., 'America/New_York') | Must be a valid IANA timezone string. Default to [DEFAULT_TIMEZONE] if not specified. Reject if the model uses an ambiguous abbreviation like 'EST'. | |
ambiguity_flag | boolean | Must be true if multiple interpretations exist (e.g., fiscal vs. calendar year). If true, confidence_score must be < 0.95 and resolution_notes must describe the tie-break. | |
fiscal_year_start_month | integer (1-12) or null | If [FISCAL_CALENDAR] is provided, validate that boundary calculations align with this month. If null, assume calendar year. Reject if the output contradicts the provided fiscal start. |
Common Failure Modes
Date and time normalization prompts fail in predictable ways that corrupt downstream retrieval filters. These cards cover the most frequent production failure modes and how to guard against them before they reach your metadata index.
Timezone Assumption Drift
What to watch: The model defaults to UTC or its training-time timezone when the user's locale is ambiguous, producing off-by-one-day date ranges for 'today' or 'tomorrow' queries. This is especially dangerous for global applications where 'end of day' means different boundaries per region. Guardrail: Always inject the user's resolved IANA timezone string (e.g., America/Chicago) into the prompt as a required input field. Validate that the output ISO 8601 range includes the correct UTC offset before accepting it.
Ambiguous Boundary Date Resolution
What to watch: Expressions like 'last week', 'this month', or 'next quarter' have multiple valid interpretations depending on locale (Sunday vs. Monday week start) and fiscal calendar alignment. The model silently picks one convention without flagging ambiguity, leading to incorrect metadata filter ranges. Guardrail: Require the prompt to output a boundary_convention field (e.g., week_start: monday, fiscal_year_start: april) alongside the date range. If the convention cannot be inferred, set confidence: low and trigger a clarification path.
Relative Expression Staleness
What to watch: The prompt resolves 'now', 'today', or 'current' using the model's training cutoff or the timestamp of a cached response rather than the actual query execution time. A query run at 11:59 PM produces a date range that is stale by the time retrieval executes. Guardrail: Pass an explicit reference_timestamp in ISO 8601 as a required input. Never rely on the model to infer the current time. Log the reference timestamp alongside the normalized output for auditability.
Underspecified Duration Collapse
What to watch: Queries like 'recent reports' or 'older transactions' contain vague temporal adjectives with no standard mapping to concrete ranges. The model hallucinates a duration (e.g., 'last 30 days') without evidence, producing overconfident but arbitrary filters. Guardrail: Add a vagueness_score field to the output schema. When the score exceeds a threshold, force the system to either ask a clarification question or fall back to a broader retrieval strategy without a date filter rather than guessing.
Fiscal vs. Calendar Calendar Confusion
What to watch: Enterprise users say 'Q2' meaning their fiscal quarter, but the model defaults to calendar quarters (Jan–Mar, Apr–Jun, etc.). The resulting date range is off by months, silently retrieving the wrong documents. Guardrail: Provide an optional fiscal_calendar input mapping quarter labels to month ranges. If the input is absent and the query mentions quarters, the prompt must flag confidence: low and note the assumption in the output rather than silently defaulting to calendar quarters.
Holiday and Non-Standard Period Mapping
What to watch: Expressions like 'over the holidays', 'Black Friday week', or 'end of financial year' map to culturally or regionally specific date ranges that the model may get wrong or resolve inconsistently across calls. Guardrail: Maintain a domain-specific period_alias_map (e.g., holiday_season: 2025-11-27/2025-12-31) as an input or retrieval-time lookup. If a query references a period not in the map, the prompt must return unmapped_period: true and escalate rather than guess.
Evaluation Rubric
Use this rubric to test the Date and Time Expression Normalization prompt before deploying it in a production RAG pipeline. Each criterion targets a known failure mode for relative time parsing.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
ISO 8601 Range Format | Output contains valid start_date and end_date strings in YYYY-MM-DD format. | Output is a Unix timestamp, a non-standard date string, or a single date when a range is expected. | Parse output with a strict ISO 8601 date validator. Reject any output that fails to parse. |
Relative Quarter Resolution | For [INPUT] 'last quarter', output maps to the correct previous fiscal or calendar quarter based on [REFERENCE_DATE]. | Output maps to the current quarter, the wrong previous quarter, or an incorrect year boundary. | Run a parameterized test for each quarter boundary (e.g., Jan 1, Apr 1) and assert the correct start/end dates. |
Ambiguous Boundary Handling | For [INPUT] 'this weekend', output includes a confidence_score less than 0.9 and a disambiguation_note explaining the assumption. | Output has a high confidence score for an ambiguous term or provides no note about the boundary assumption. | Test with locale-ambiguous terms ('next weekend', 'end of day') and assert the presence of a non-null disambiguation_note. |
Timezone-Aware Output | Output includes a timezone_offset field matching the provided [USER_TIMEZONE] and adjusts the date range boundary times accordingly. | Output ignores the [USER_TIMEZONE] variable, returns UTC by default, or applies an incorrect offset. | Provide a [USER_TIMEZONE] of 'America/New_York' and verify the offset is -05:00 or -04:00 depending on [REFERENCE_DATE]. |
Granularity Preservation | For [INPUT] 'next Monday at 3 PM', the output includes a time component in the ISO 8601 string. | Output truncates the time component and returns only a date, losing the user's specified precision. | Assert that the length of the start_date string is greater than 10 characters when the input contains a time expression. |
Invalid Input Handling | For [INPUT] 'blarg blarg', the output has a confidence_score of 0.0 and a valid error_message. | Output hallucinates a date range, returns a null object without an error, or throws an unhandled exception. | Send a non-temporal string and assert that confidence_score is 0.0 and error_message is not null. |
Future Date Projection | For [INPUT] 'next month' with a [REFERENCE_DATE] in December, the output correctly projects to January of the following year. | Output returns a date in the past, or fails to increment the year, returning January of the current year. | Set [REFERENCE_DATE] to '2025-12-15' and assert that the output start_date is in January 2026. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single example and minimal output constraints. Focus on getting correct ISO 8601 ranges for common relative expressions like 'last week' or 'next month'. Drop the confidence flag and timezone handling initially.
codeNormalize this time expression into an ISO 8601 date range: [USER_QUERY]
Watch for
- Ambiguous boundary dates (e.g., 'last quarter' interpreted differently across fiscal calendars)
- Missing reference date causing the model to assume 'now' incorrectly
- No validation that the output range is logically consistent (start before end)

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us