Inferensys

Prompt

Since and Until Boundary Extraction Prompt

A practical prompt playbook for using Since and Until Boundary Extraction Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define when explicit boundary extraction is the right tool and when simpler or different approaches are required.

This prompt is designed for retrieval pipeline builders who need to parse explicit temporal boundary markers from user queries—phrases like 'since January', 'until last month', or 'from 2020 onward'. The job-to-be-done is converting natural language boundary expressions into structured start and end constraints with clear operator semantics (inclusive, exclusive, open-ended) that can be directly translated into metadata filter clauses for vector databases, search indexes, or SQL WHERE conditions. The ideal user is a RAG developer or search engineer who already has a retrieval system that supports date-range filtering and needs reliable extraction of boundary intent from user queries.

Use this prompt when your retrieval system requires explicit start and end boundaries rather than relative date ranges. It is specifically designed for queries that contain boundary markers like 'since', 'until', 'from', 'after', 'before', 'up to', or 'onward'. The prompt produces structured output with start and end objects, each containing a date value, an operator (gte, gt, lte, lt, or null for open boundaries), and a confidence flag. This is distinct from relative date normalization prompts that convert 'last quarter' into ISO ranges—this prompt assumes the user has already provided explicit boundary language and needs operator disambiguation. For example, 'since January 2024' should produce a start boundary with gte (inclusive) while 'after January 2024' should produce gt (exclusive).

Do not use this prompt for queries that express relative time periods without boundary markers ('last 30 days', 'recent', 'this quarter'). Those queries should be routed to relative date normalization or temporal vagueness detection prompts instead. Also avoid this prompt when the retrieval system does not support boundary operators and only accepts concrete date ranges—in that case, pair this prompt with a downstream resolution step that converts operator semantics into explicit dates. For high-stakes applications like legal document retrieval or financial compliance, always add a validation layer that checks extracted boundaries against the source query and logs any ambiguous cases for human review. The prompt works best as part of a pre-retrieval pipeline stage, positioned after query disambiguation and before metadata filter construction.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the Since and Until Boundary Extraction Prompt is the right tool for your retrieval pipeline.

01

Good Fit: Explicit Boundary Markers

Use when: queries contain clear boundary language such as 'since January', 'until last month', 'from 2020 onward', or 'between March and June'. The prompt excels at extracting start and end points with operator semantics (gte, lte, gt, lt) when the user provides explicit anchors. Guardrail: pre-filter queries with a lightweight classifier to confirm boundary markers exist before invoking extraction.

02

Bad Fit: Implicit or Vague Temporality

Avoid when: queries use vague recency terms like 'recent', 'latest', or 'current' without explicit boundary words. This prompt targets 'since' and 'until' syntax, not relative time normalization. Guardrail: route vague temporal queries to the Relative Date Normalization or Recent and Latest Disambiguation prompts instead. Use a dispatcher to classify query type before extraction.

03

Required Inputs: Query Text and Reference Date

What you must provide: the raw user query string and an explicit reference date (ISO 8601) to anchor resolution. Without a reference date, 'since last month' cannot resolve to concrete boundaries. Guardrail: inject a session-level temporal anchor from your application context. If no reference date is available, reject the extraction and request clarification rather than guessing.

04

Operational Risk: Open-Ended Ranges

What to watch: queries like 'since 2020' produce only a start boundary with no end constraint. Downstream metadata filters must handle open-ended ranges correctly or risk scanning entire partitions. Guardrail: always validate extracted boundaries for completeness. If one side is missing, apply a sensible default end boundary (e.g., current date) or flag the range as open in your filter construction logic.

05

Operational Risk: Boundary Operator Ambiguity

What to watch: natural language like 'since January' could mean inclusive (>= Jan 1) or exclusive (> Jan 1). Misinterpreting the operator produces off-by-one errors in retrieval. Guardrail: include explicit operator semantics in the prompt output schema (gte, gt, lte, lt). Test edge cases with a golden dataset that covers inclusive vs. exclusive phrasing. Log operator decisions for audit.

06

Bad Fit: Multi-Part or Nested Temporal Logic

Avoid when: queries contain complex temporal logic such as 'since January but not including March' or 'from 2020 to 2022 except Q3'. This prompt extracts simple start-end pairs, not exclusion sets or union ranges. Guardrail: decompose complex temporal queries upstream using Query Decomposition prompts. Apply boundary extraction to each sub-query independently, then combine filters with explicit AND/OR/NOT logic in your retrieval layer.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that extracts explicit start and end boundaries from temporal expressions like 'since January' or 'until last month' and returns structured operator semantics for metadata filter construction.

This prompt template is designed to be dropped directly into a retrieval pipeline preprocessing step. It takes a raw user query containing boundary markers such as 'since', 'until', 'from', 'after', 'before', or 'between' and extracts the intended start and end points along with the correct comparison operators (gte, lte, gt, lt). The output is a structured JSON object ready to be consumed by a metadata filter builder, not a natural language explanation. The template uses square-bracket placeholders so you can inject the user query, a reference date, and any domain-specific constraints without modifying the core instruction.

text
You are a temporal boundary extraction system. Your job is to parse explicit boundary markers from a user query and return structured start and end constraints with operator semantics.

INPUT:
- User Query: [USER_QUERY]
- Reference Date (ISO 8601): [REFERENCE_DATE]
- Timezone: [TIMEZONE]

OUTPUT_SCHEMA:
Return a valid JSON object with this exact structure:
{
  "start": {
    "value": "ISO 8601 date string or null",
    "operator": "gte | gt | null",
    "original_text": "the exact phrase from the query that produced this boundary or null"
  },
  "end": {
    "value": "ISO 8601 date string or null",
    "operator": "lte | lt | null",
    "original_text": "the exact phrase from the query that produced this boundary or null"
  },
  "is_open_ended": true or false,
  "boundary_type": "explicit_start_only | explicit_end_only | explicit_range | implicit | none",
  "confidence": 0.0 to 1.0
}

CONSTRAINTS:
- Only extract boundaries that are explicitly stated in the query. Do not infer or assume ranges.
- If the query says 'since January 2024', the start operator is 'gte' and the end is null.
- If the query says 'until last month', the end operator is 'lte' and the start is null.
- If the query says 'from March to June 2024', the start operator is 'gte' and the end operator is 'lte'.
- If the query says 'after Q2 2023', the start operator is 'gt'.
- If the query says 'before 2020', the end operator is 'lt'.
- Resolve all relative expressions using the provided reference date and timezone.
- If no boundary markers are present, set both start and end values to null, is_open_ended to true, boundary_type to 'none', and confidence to 1.0.
- If a boundary is mentioned but cannot be resolved to a date, set its value to null, keep the original_text, and set confidence below 0.5.
- Return only the JSON object. No markdown, no explanation.

EXAMPLES:

Query: 'revenue reports since January 2024'
Reference Date: 2025-01-15
Timezone: America/New_York
Output:
{
  "start": {
    "value": "2024-01-01",
    "operator": "gte",
    "original_text": "since January 2024"
  },
  "end": {
    "value": null,
    "operator": null,
    "original_text": null
  },
  "is_open_ended": true,
  "boundary_type": "explicit_start_only",
  "confidence": 0.95
}

Query: 'contracts signed until last month'
Reference Date: 2025-03-10
Timezone: UTC
Output:
{
  "start": {
    "value": null,
    "operator": null,
    "original_text": null
  },
  "end": {
    "value": "2025-02-28",
    "operator": "lte",
    "original_text": "until last month"
  },
  "is_open_ended": true,
  "boundary_type": "explicit_end_only",
  "confidence": 0.95
}

Query: 'sales data between Q1 2023 and Q3 2023'
Reference Date: 2025-01-01
Timezone: UTC
Output:
{
  "start": {
    "value": "2023-01-01",
    "operator": "gte",
    "original_text": "between Q1 2023"
  },
  "end": {
    "value": "2023-09-30",
    "operator": "lte",
    "original_text": "and Q3 2023"
  },
  "is_open_ended": false,
  "boundary_type": "explicit_range",
  "confidence": 0.95
}

Query: 'latest product specs'
Reference Date: 2025-01-15
Timezone: America/Chicago
Output:
{
  "start": {
    "value": null,
    "operator": null,
    "original_text": null
  },
  "end": {
    "value": null,
    "operator": null,
    "original_text": null
  },
  "is_open_ended": true,
  "boundary_type": "none",
  "confidence": 1.0
}

RISK_LEVEL: LOW. This prompt performs deterministic extraction. Failures produce null boundaries rather than hallucinated dates.

Adapt this template by replacing the [USER_QUERY], [REFERENCE_DATE], and [TIMEZONE] placeholders at runtime. The reference date should typically be the current date or the session's temporal anchor point. If your retrieval system uses a different filter syntax, modify the OUTPUT_SCHEMA description but preserve the operator semantics. For high-stakes retrieval pipelines where a wrong boundary could exclude critical documents, add a post-extraction validation step that checks whether the extracted range is logically consistent before constructing the metadata filter. The confidence field is your signal for when to route to human review or fall back to an unbounded search.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Since and Until Boundary Extraction Prompt. Each variable must be validated before the prompt is sent to prevent ambiguous or unparseable boundary outputs.

PlaceholderPurposeExampleValidation Notes

[USER_QUERY]

The raw natural language query containing explicit boundary markers like 'since', 'until', 'from', 'to', or 'onward'

Show me revenue since January 2024 until last month

Must contain at least one boundary marker token. If absent, return an empty extraction result rather than guessing. Check with regex for boundary keywords before invoking the prompt.

[REFERENCE_DATE]

The anchor date used to resolve relative expressions like 'last month' or 'yesterday'. Defaults to the current system date if not provided.

2025-03-15

Must be ISO 8601 date string (YYYY-MM-DD). If null or malformed, the prompt must abort with a configuration error. Validate with a date parsing library before injection.

[TIMEZONE]

IANA timezone identifier for resolving day-boundary-sensitive expressions and aligning output ranges to the user's locale.

America/Chicago

Must be a valid IANA timezone string. If null, default to 'UTC' and log a warning. Validate against a timezone database list. Incorrect timezone causes off-by-one-day boundary errors.

[OUTPUT_SCHEMA]

The expected JSON structure for the extracted boundaries, including fields for start_date, end_date, start_operator, end_operator, and confidence.

{"start_date": "2024-01-01", "end_date": "2025-02-28", "start_operator": "gte", "end_operator": "lte"}

Must be a valid JSON Schema object. Validate with a schema validator before prompt assembly. Reject if required fields (start_date, end_date) are missing from the schema definition.

[ALLOW_OPEN_RANGES]

Boolean flag controlling whether the prompt can return null for start_date or end_date when the query specifies only one boundary (e.g., 'since 2023' with no end).

Must be a strict boolean. If false, the prompt must return an error for open-ended queries rather than guessing a boundary. If true, null start_date or end_date values must pass post-extraction validation.

[DEFAULT_RANGE_DAYS]

Fallback range in days applied when the query implies a bounded period but no explicit boundary is extractable. Used only when ALLOW_OPEN_RANGES is false.

90

Must be a positive integer. If null and ALLOW_OPEN_RANGES is false, the prompt must return a clarification request instead of fabricating a range. Validate as integer > 0 before injection.

[OPERATOR_MAP]

Mapping of boundary intent words to filter operators for the target database query language.

{"since": "gte", "until": "lte", "from": "gte", "to": "lte", "after": "gt", "before": "lt"}

Must be a valid JSON object with string keys and values. Validate that all values are in the allowed operator set for the target database (e.g., gte, lte, gt, lt, eq). Missing mappings cause incorrect filter clause generation.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Since and Until Boundary Extraction Prompt into a production retrieval pipeline with validation, retries, and metadata filter construction.

The Since and Until Boundary Extraction Prompt is designed to sit immediately before retrieval execution in a RAG or hybrid search pipeline. Its job is to parse explicit boundary markers like 'since January', 'until last month', or 'from 2020 onward' from a user query and produce structured start and end boundaries with operator semantics (gte, lte, gt, lt). The output is not a final answer—it is a metadata filter payload that your application layer uses to construct database WHERE clauses, vector DB filter expressions, or Elasticsearch range queries. This prompt should be called after any query rewriting or decomposition steps but before the retrieval call itself.

Integration pattern: Your application receives a user query, extracts the raw text, and passes it to this prompt along with a reference timestamp (typically now() in UTC). The model returns a JSON object with start, end, start_operator, end_operator, and an is_open_ended flag. Your harness then validates the output before constructing the retrieval filter. Key validation checks include: (1) confirm that start and end are valid ISO 8601 strings or null, (2) verify that start is not after end when both are present, (3) ensure operators are one of the allowed set (gte, gt, lte, lt), and (4) reject any output where is_open_ended is true but the query contained explicit boundary language that should have resolved to a concrete range. If validation fails, log the failure, capture the raw query and model output for debugging, and either retry with a more constrained prompt or fall back to a default recency window (e.g., last 90 days) rather than executing a broken filter.

Retry and fallback logic: When the model produces an invalid or unparseable output, implement a single retry with the same prompt but append the validation error message as additional context. For example: The previous output failed validation: start date is after end date. Please correct. If the retry also fails, do not loop indefinitely. Instead, fall back to a safe default range (e.g., no temporal filter, or a configurable default window like the past year) and emit a warning metric. This prevents a prompt failure from breaking the entire retrieval pipeline. Log every fallback event with the original query, the failed output, and the fallback range applied so you can tune the prompt or add few-shot examples for recurring failure patterns.

Metadata filter construction: Once you have a validated boundary object, map it to your specific retrieval backend. For a vector database with metadata filtering, the start and start_operator become a filter clause like {"date": {"$gte": "2024-01-01T00:00:00Z"}}. For Elasticsearch, construct a range query on your timestamp field. For SQL-backed retrieval, build a parameterized WHERE clause. Always parameterize the values rather than interpolating strings to avoid injection risks. If is_open_ended is true and only one boundary exists, construct a single-sided range filter. If both boundaries are null (the query contained no temporal language), skip the temporal filter entirely rather than applying an unnecessary constraint.

Observability and evaluation: Instrument this prompt with production tracing that captures: the raw user query, the reference timestamp used, the raw model output, validation pass/fail, retry count, fallback activation, and the final filter clause applied. For offline evaluation, maintain a golden dataset of queries with known temporal boundaries (e.g., 'since March 2024' → start=2024-03-01, end=null, start_operator=gte). Run this eval suite on every prompt change and model upgrade. Pay special attention to boundary inclusion errors—cases where the model uses gt when gte is correct, or vice versa—as these are the most common and impactful failure mode in production retrieval. If your use case involves financial, legal, or compliance documents where date precision is critical, add a human review step for any query where the model's confidence appears low or where the extracted range would filter out documents that a reasonable user would expect to see.

IMPLEMENTATION TABLE

Expected Output Contract

The prompt must return a structured object with start and end boundaries, operator semantics, and confidence flags. Use this contract to validate the model's output before constructing metadata filter clauses.

Field or ElementType or FormatRequiredValidation Rule

start_boundary

ISO 8601 date string (YYYY-MM-DD) or null

Must be a valid date or null for open-ended ranges. If null, start_operator must be 'unbounded'.

end_boundary

ISO 8601 date string (YYYY-MM-DD) or null

Must be a valid date or null for open-ended ranges. If null, end_operator must be 'unbounded'.

start_operator

enum: 'gte', 'gt', 'unbounded'

Must be one of the three allowed values. 'unbounded' only allowed when start_boundary is null.

end_operator

enum: 'lte', 'lt', 'unbounded'

Must be one of the three allowed values. 'unbounded' only allowed when end_boundary is null.

confidence

float between 0.0 and 1.0

Must be a number. Values below 0.7 should trigger a clarification request or human review in high-stakes pipelines.

boundary_source

string

Must quote the exact substring from [USER_QUERY] that was used to derive the boundaries. Empty string if no explicit boundary marker was found.

assumptions

array of strings

If present, each entry must describe one assumption made during resolution, such as timezone defaults or fiscal calendar choices. Required when confidence is below 0.9.

reference_date_used

ISO 8601 date string (YYYY-MM-DD)

Must match the [REFERENCE_DATE] input. If the model infers a different reference date, this field must flag the deviation and the assumption must be listed.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when extracting since/until boundaries and how to guard against it.

01

Open-Ended Range Ambiguity

What to watch: Queries like 'since January' or 'from 2020 onward' produce only a start boundary with no explicit end. The model may hallucinate an end date, default to 'now,' or leave the field null. Guardrail: Require an explicit end field in the output schema. If no end is stated, set it to the current date and annotate with "boundary_type": "open" to make the assumption traceable.

02

Operator Semantics Drift

What to watch: The prompt may return gte/lte when the user's language implies strict inequality (>/<). 'Until last month' vs. 'through last month' changes whether the boundary is inclusive or exclusive. Guardrail: Include an operator field (gte, gt, lte, lt) in the output schema and test edge cases with explicit inclusive/exclusive phrasing in your eval set.

03

Implicit Reference Date Mismatch

What to watch: 'Since last month' resolves differently depending on whether the reference date is today, the conversation start, or the document timestamp. Without an explicit anchor, the model picks a default that may not match the retrieval context. Guardrail: Always inject a reference_date parameter into the prompt. Log the anchor used so downstream filter construction is auditable.

04

Missing Boundary When Only One Marker Exists

What to watch: Queries containing only 'until' or only 'since' cause the model to omit the other boundary entirely rather than marking it as null or open. Downstream filter builders then fail on missing keys. Guardrail: Enforce that both start and end fields are always present in the output, using null with an explicit reason field when a boundary is absent.

05

Date Resolution Granularity Errors

What to watch: 'Since 2023' should resolve to 2023-01-01, not 2023-06-15. The model may hallucinate a mid-year date or default to the current month. Guardrail: Include a resolution rule in the system prompt: year-only inputs map to January 1st, month-only inputs map to the first day of that month. Validate with unit tests for each granularity level.

06

Future-Dated Boundary Leakage

What to watch: 'Until next quarter' or 'through end of year' can produce boundaries far in the future. If the retrieval index only contains historical documents, these queries return empty results without warning. Guardrail: Add a post-extraction validation step that compares extracted boundaries against the corpus date range. Flag future-only ranges and suggest relaxation before retrieval executes.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Since and Until Boundary Extraction Prompt before deploying it in a retrieval pipeline. Each criterion targets a specific failure mode observed in temporal boundary extraction.

CriterionPass StandardFailure SignalTest Method

Explicit Start Boundary Extraction

Correctly extracts the start date from 'since [DATE]' and sets the operator to 'gte'.

Start date is null, operator is 'eq', or the date is parsed incorrectly.

Run with 'since January 2024'. Assert output.start.date equals '2024-01-01' and output.start.operator equals 'gte'.

Explicit End Boundary Extraction

Correctly extracts the end date from 'until [DATE]' and sets the operator to 'lte'.

End date is null, operator is 'eq', or the date is parsed incorrectly.

Run with 'until last month'. Given a reference date of 2024-07-15, assert output.end.date equals '2024-06-30' and output.end.operator equals 'lte'.

Open-Ended Range Handling

When only a start boundary is present, the end boundary object is null. When only an end boundary is present, the start boundary object is null.

Missing boundary is populated with a default or hallucinated date.

Run with 'since March'. Assert output.end is null. Run with 'until Friday'. Assert output.start is null.

Implicit Boundary Detection

Flags that no explicit boundary markers were found and returns null for both start and end.

The model invents boundaries or misinterprets non-temporal text as a boundary.

Run with 'sales data for the northeast region'. Assert output.start is null and output.end is null.

Relative Date Normalization

Converts relative dates like 'last month' or 'yesterday' to absolute ISO 8601 dates based on the provided [REFERENCE_DATE].

Output contains the relative string instead of a date, or the calculation is off by one day/month.

Run with 'since yesterday' and a reference date of 2024-03-01. Assert output.start.date equals '2024-02-29'.

Operator Semantics

Uses 'gte' for 'since'/'from'/'after' and 'lte' for 'until'/'before'/'through'.

Operator is 'gt' or 'lt' when the boundary is inclusive, or the operator is missing.

Run with 'from 2023 onward'. Assert output.start.operator equals 'gte'. Run with 'before June'. Assert output.end.operator equals 'lte'.

Ambiguous Input Handling

Returns a confidence score below the threshold and provides a clarification note when the boundary is ambiguous.

The model guesses a date with high confidence or fails to flag the ambiguity.

Run with 'since the start of the quarter' without a fiscal calendar. Assert output.confidence is less than 0.8 and output.clarification_needed is true.

Output Schema Compliance

The output strictly matches the defined [OUTPUT_SCHEMA] with all required fields present and correctly typed.

Fields are missing, extra fields are present, or data types are wrong (e.g., date is not a string).

Parse the raw output with a JSON schema validator. Assert no validation errors against the expected schema.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single reference date and minimal output validation. Accept the raw boundary extraction without enforcing operator semantics or schema checks.

code
Extract start and end boundaries from: [QUERY]
Reference date: [REFERENCE_DATE]

Watch for

  • Open-ended ranges producing null or empty strings instead of explicit null markers
  • Ambiguous markers like "since last year" resolving inconsistently across runs
  • Missing operator semantics (gte, lte, gt, lt) when you later need them for filter construction
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.