This prompt is designed for document pipeline engineers who need to extract effective dates, signature dates, revision timestamps, and other metadata-level dates from documents and normalize them into ISO-8601 timestamps. The job-to-be-done is reliable, auditable date extraction that downstream systems can ingest without manual cleanup. The ideal user is building or maintaining a document intelligence pipeline—ingesting contracts, reports, filings, or forms—where date accuracy directly affects compliance, sorting, filtering, or deadline calculations.
Prompt
Date and Timestamp Extraction Prompt from Document Metadata

When to Use This Prompt
Define the job, ideal user, and operational boundaries for the Date and Timestamp Extraction Prompt.
Use this prompt when you have already extracted document metadata fields (such as effective_date, signature_date, last_modified, or revision_date) and need to resolve them into a single normalized format with source-field attribution. It is appropriate when documents may contain conflicting date fields, ambiguous formats (e.g., 03/04/2024 vs. 04/03/2024), or partial timestamps. The prompt expects structured metadata as input, not raw document text. It requires you to supply a schema of expected date fields and their priority order for conflict resolution.
Do not use this prompt for extracting dates from unstructured body text, for parsing natural-language relative dates ("next Tuesday"), or for timezone-sensitive scheduling logic. It is not a replacement for a date parsing library—it is a normalization and disambiguation layer that sits between raw extraction and database insertion. Avoid using it when the input metadata is already in a single canonical format with no conflicts; a simple transformation function will be cheaper and more reliable. For high-risk documents such as legal contracts or regulatory filings, always route low-confidence outputs to a human review queue before the normalized dates enter a system of record.
Use Case Fit
Where this prompt works and where it does not. Use these cards to quickly assess if the Date and Timestamp Extraction Prompt is the right tool for your document pipeline stage.
Good Fit: Structured Metadata Extraction
Use when: you need to extract dates from document headers, footers, signature blocks, or revision tables where the date string is explicit (e.g., 'Effective Date: 2023-10-24'). Guardrail: The prompt excels at parsing explicit date strings and normalizing them to ISO-8601, not inferring dates from narrative text.
Bad Fit: Narrative Date Reasoning
Avoid when: the document only implies a date through context (e.g., 'the following quarter' or 'last Tuesday'). Risk: The model will hallucinate a specific date or default to the document's creation date. Guardrail: Route these documents to a human review queue or a separate temporal reasoning prompt before extraction.
Required Inputs: Source Field Attribution
Risk: Extracting a date without its source field (e.g., '2024-01-15') creates an unverifiable record. Guardrail: The prompt template must require a source_field for every extracted date, mapping it back to the exact key or zone in the document metadata to maintain an audit trail.
Operational Risk: Conflicting Date Fields
What to watch: Documents often contain multiple dates (created, modified, signed, effective) that conflict. Guardrail: The prompt must include an ambiguity_resolution field that flags conflicts and explains the resolution logic (e.g., 'Signature Date overrides Revision Date for legal standing') rather than silently picking one.
Operational Risk: Time Zone Ambiguity
What to watch: A timestamp like '2023-12-01T23:00:00' is meaningless without a UTC offset. Guardrail: The output schema must strictly enforce the ISO-8601 extended format with a timezone designator (e.g., -05:00 or Z). If the source is ambiguous, the prompt must flag it and default to UTC with a warning.
Bad Fit: Scanned Documents with OCR Noise
Avoid when: the primary input is a low-quality scan where OCR might mangle digits (e.g., '2O23' instead of '2023'). Risk: The model will confidently normalize a corrupted string. Guardrail: This prompt should only run after a validated OCR pipeline. Pair it with a pre-processing check that flags low-confidence character recognition on numeric fields.
Copy-Ready Prompt Template
A reusable prompt for extracting normalized dates and timestamps from document metadata with source attribution and ambiguity resolution.
This prompt template is designed to be dropped into a document processing pipeline where you need to extract every meaningful date and timestamp from a document's metadata, header blocks, signature sections, and revision history. It forces the model to produce normalized ISO-8601 output, attribute each extracted date to its source field, and flag any ambiguity or conflict rather than silently picking a winner. The square-bracket placeholders let you adapt it to your specific document type, risk tolerance, and downstream schema without rewriting the core extraction logic.
textYou are a precise date and timestamp extraction system. Your task is to extract every date and timestamp present in the provided document metadata and content, normalize them to ISO-8601 format, and return a structured JSON record with source attribution and ambiguity notes. ## INPUT Document content with metadata fields: [DOCUMENT_CONTENT] ## OUTPUT_SCHEMA Return a JSON object with the following structure: { "extracted_dates": [ { "date_type": "string (e.g., effective_date, signature_date, revision_date, expiration_date, created_date, metadata_date)", "original_value": "string (the raw text as it appears in the document)", "normalized_value": "string (ISO-8601 format: YYYY-MM-DD or YYYY-MM-DDThh:mm:ss±hh:mm)", "source_field": "string (the document field, header key, or section where this date was found)", "confidence": "number (0.0 to 1.0)", "ambiguity_notes": "string or null (explain any parsing ambiguity, conflicting formats, or assumptions made)" } ], "conflicts": [ { "date_type": "string", "conflicting_values": ["string", "string"], "resolution_note": "string (explain the conflict and why it could not be resolved automatically)" } ], "extraction_metadata": { "total_dates_found": "number", "dates_with_high_confidence": "number", "dates_requiring_review": "number", "processing_note": "string (summary of any systemic issues encountered)" } } ## CONSTRAINTS - Extract ALL dates, not just the most obvious ones. Include dates from headers, footers, metadata blocks, signature lines, revision tables, and embedded document properties. - Normalize every date to ISO-8601. For ambiguous formats (e.g., 01/02/2024), use context clues from the document to resolve month/day ordering. If unresolvable, flag it in ambiguity_notes and set confidence below 0.7. - If the same logical date appears in multiple places with different values, record each as a separate entry and add a conflict record. - For timestamps with timezone information, preserve the offset. For timestamps without timezone, note "no timezone specified" in ambiguity_notes. - If a date field is present but empty or unreadable, do not include it. Do not hallucinate dates. - Set confidence to 1.0 only when the date is unambiguous and machine-readable. Reduce confidence for OCR-derived dates, handwritten dates, or ambiguous formats. - If [RISK_LEVEL] is "high", flag any date with confidence below 0.9 for human review. ## EXAMPLES [FEW_SHOT_EXAMPLES] ## OUTPUT INSTRUCTIONS Return ONLY the JSON object. No markdown fences, no commentary, no additional text.
Adaptation notes: Replace [DOCUMENT_CONTENT] with the raw text and metadata fields from your document pipeline. Set [RISK_LEVEL] to "high" for legal, financial, or compliance workflows where a wrong date has material consequences—this activates the human-review flagging logic. Populate [FEW_SHOT_EXAMPLES] with 2-4 examples from your actual document corpus showing tricky cases like multi-format dates, timezone handling, and conflicting effective dates. If your downstream system expects a different schema, modify the OUTPUT_SCHEMA block but preserve the source_field, confidence, and ambiguity_notes fields—these are what make the extraction auditable. For production, pair this prompt with a JSON schema validator that rejects malformed output and triggers a retry with the error message appended to the prompt.
Prompt Variables
Required and optional inputs for the Date and Timestamp Extraction Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to check that the input is fit for purpose before extraction begins.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DOCUMENT_TEXT] | Full text of the document from which dates and timestamps will be extracted | This Agreement is made effective as of January 15, 2024... | Must be non-empty string. Check for encoding issues, OCR artifacts, and truncated content before passing. Minimum 10 characters. |
[DOCUMENT_TYPE] | Type of document being processed to guide extraction priorities | contract | Must be one of: contract, report, form, correspondence, filing, policy, invoice, or general. Used to weight which date fields are primary. |
[TARGET_DATE_FIELDS] | List of date field names to extract with descriptions | ["effective_date", "signature_date", "revision_date", "expiration_date"] | Must be a valid JSON array of strings. Each field should have a clear definition in the prompt instructions. Empty array triggers extraction of all detected dates. |
[OUTPUT_TIMEZONE] | IANA timezone for normalizing all extracted timestamps | America/New_York | Must be a valid IANA timezone string. Default to UTC if not specified. Check that the timezone matches the document's jurisdiction or business context. |
[AMBIGUITY_RESOLUTION] | Rules for resolving ambiguous date formats like 01/02/2024 | prefer_iso_yyyy_mm_dd | Must be one of: prefer_iso_yyyy_mm_dd, prefer_locale_us, prefer_locale_eu, flag_all_ambiguous. Incorrect setting causes systematic date misinterpretation across the batch. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for auto-accepting an extracted date without human review | 0.85 | Must be a float between 0.0 and 1.0. Dates below this threshold should be routed to human review queue. Set to null to disable auto-accept. |
[MAX_EXTRACTION_ATTEMPTS] | Maximum number of retry attempts if validation fails on the output schema | 3 | Must be a positive integer. Each retry should include the validation error message. Set to 1 to disable retries and fail immediately on invalid output. |
[SOURCE_DOCUMENT_ID] | Unique identifier for the document being processed for traceability and audit logs | doc_2024_03_15_001 | Must be a non-empty string. Used in output records for source attribution. Should match the document registry or storage system identifier. |
Implementation Harness Notes
How to wire the date extraction prompt into a production document pipeline with validation, retries, and human review.
This prompt is designed to be called after document text and metadata have been extracted from the source file (PDF, DOCX, email, etc.) but before the normalized dates are written to your target system. The harness should pass the raw document metadata dictionary and the extracted body text as structured inputs, not as a single flat string. Keep the metadata fields separate so the model can attribute each extracted date to its source field (e.g., pdf:created, exiftool:DateTimeOriginal, email:Date). The prompt expects a JSON output matching the defined schema, which your harness must validate before ingestion.
Validation and retry logic: Parse the model's JSON output and validate it against the expected schema. Check that every iso8601 field is a valid ISO-8601 string, that source_field references a real input field, and that ambiguity_notes is present when confidence is below your threshold (we recommend 0.85). If validation fails, retry once with the validation error message appended to the prompt as additional context. If the retry also fails, route the document to a human review queue with the raw metadata, extracted text, and both failed outputs attached. Do not silently drop dates or fall back to a best-guess without logging the ambiguity.
Model choice and tool use: This extraction task works well with capable mid-tier models (GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro) because it requires structured output adherence and reasoning about temporal ambiguity. If your pipeline processes high volumes, consider using a faster model for the initial extraction and a stronger model for the retry-on-failure path. Do not use function calling for this prompt—the output is a data payload, not an action. The model should return the JSON directly. For documents with embedded timestamps in multiple time zones, include a [TIMEZONE_HINT] variable in the prompt to reduce ambiguity.
Logging and observability: Log every extraction attempt with the document ID, model version, prompt version, raw output, validation result, and final ingested dates. This audit trail is critical when downstream systems rely on extracted effective dates, signature dates, or revision timestamps. If you detect a pattern of low-confidence extractions from a specific document source or format, use those logs to improve your preprocessing or add few-shot examples to the prompt. Never assume the model's date normalization is correct without comparing extracted dates against known document events where ground truth is available.
Expected Output Contract
Defines the required shape, types, and validation rules for the normalized date extraction output. Use this contract to build downstream parsers and validation checks before ingesting extracted timestamps into a database or event stream.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
extracted_date | ISO-8601 string (YYYY-MM-DD) | Must parse as a valid date. Reject if month or day is 00. If time component is present, it must be truncated or stored in a separate timestamp field. | |
source_field | string | Must exactly match one of the provided [SOURCE_FIELDS] enum values. Reject if the value is not in the allowed list. | |
confidence | number (0.0 to 1.0) | Must be a float between 0.0 and 1.0 inclusive. Values below [CONFIDENCE_THRESHOLD] must trigger a human review flag in the application layer. | |
ambiguity_notes | string or null | If not null, must be a non-empty string explaining the ambiguity. Required if multiple conflicting dates exist for the same source_field. | |
original_text | string | Must be a non-empty string containing the exact text span from which the date was extracted. Used for auditability and source grounding. | |
normalization_applied | string or null | If not null, must be one of: 'timezone_conversion', 'format_parsing', 'relative_date_resolution', or 'fiscal_year_conversion'. Describes the transformation applied to the raw text. | |
conflicting_dates | array of strings or null | If not null, must be an array of ISO-8601 strings representing other dates found in the same source_field. Required if ambiguity_notes is not null. |
Common Failure Modes
Date extraction from document metadata fails in predictable ways. These cards cover the most common production failure modes and the guardrails that catch them before bad timestamps enter downstream systems.
Ambiguous Date Format Collision
What to watch: The model misinterprets 03/04/2024 as March 4th when the document locale expects April 3rd. This is the most common silent failure in production date extraction. Guardrail: Always pass a locale hint or expected format in the prompt. Add a post-extraction validator that flags any date where month and day are both ≤12 and the format is ambiguous. Require explicit resolution or human review before ingestion.
Conflicting Date Fields in Metadata
What to watch: A document has creation_date, last_modified, effective_date, and signature_date that disagree. The model picks one arbitrarily or hallucinates a reconciliation without documenting the conflict. Guardrail: Require the prompt to output all discovered date fields with their source attribute names, not just a single resolved date. Add a post-processing rule that flags records where multiple date fields differ by more than 24 hours and routes them for human reconciliation.
Timezone Truncation and Offset Loss
What to watch: The model strips timezone offsets during normalization, converting 2024-11-15T14:30:00+05:30 to 2024-11-15T14:30:00Z without the offset shift, producing a timestamp that is off by hours. Guardrail: Enforce strict ISO-8601 output with timezone preservation in the output schema. Add a validator that rejects any timestamp missing an explicit offset or Z suffix. Compare extracted offsets against expected document timezone context when available.
Partial Date Inference Without Confidence Flags
What to watch: The document only contains a year (2023) or a month-year pair (March 2023), but the model fills in missing day or time components with defaults like 01 or 00:00:00 without indicating the inference. Downstream systems treat these as precise timestamps. Guardrail: Require the prompt to output a precision field (year, month, day, minute) and a confidence score for each extracted date. Reject any date with precision below the ingestion threshold unless explicitly approved.
Metadata Field Misattribution
What to watch: The model extracts a date from a header, footer, or watermark and attributes it to the wrong metadata field—for example, treating a print timestamp as the document effective date. Guardrail: Require source-span attribution in the output schema. Add a validator that cross-references extracted dates against expected metadata field semantics. Flag dates extracted from known non-authoritative zones (headers, footers, watermarks) for lower confidence.
Relative Date Expression Misinterpretation
What to watch: The document contains relative dates like effective 30 days from execution or renewal date is the first of the following month, and the model either ignores them or resolves them incorrectly without showing its work. Guardrail: Add a dedicated output field for unresolved_relative_expressions that captures the raw text and the model's resolution logic. Route any record with unresolved relative dates to a human review queue before allowing automated ingestion.
Evaluation Rubric
Use this rubric to evaluate the quality of extracted date and timestamp records before they enter downstream systems. Each criterion targets a specific failure mode common in document metadata extraction.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
ISO-8601 Format Compliance | Every extracted date in [OUTPUT] is a valid ISO-8601 string | Non-standard formats like 'Jan 5, 2024' or '5/1/24' appear in output | Parse all date fields with a strict ISO-8601 validator; reject any non-conforming string |
Source Field Attribution | Every extracted date has a non-null [SOURCE_FIELD] referencing the exact metadata key or document zone | Dates appear with null, empty, or generic source labels like 'document' | Assert that [SOURCE_FIELD] is populated and matches a known metadata key from the input schema |
Ambiguity Flag Accuracy | When multiple conflicting dates exist for the same logical event, [AMBIGUITY_FLAG] is true and [AMBIGUITY_NOTE] is non-empty | Conflicting dates are silently resolved or the flag is false when conflicts exist | Inject test documents with known date conflicts and verify flag behavior and note presence |
Null Handling for Missing Fields | Missing metadata fields produce null in the output, not hallucinated dates or empty strings | Model invents a plausible date when the source field is absent from [INPUT_METADATA] | Provide input with intentionally removed date fields and assert null output for those fields |
Timezone Preservation | Timezone offsets from [INPUT_METADATA] are preserved in the ISO-8601 output or normalized to UTC with a [TIMEZONE_NOTE] | Timezone information is silently dropped or converted without documentation | Compare input timezone offsets to output; flag any mismatch without a corresponding note |
Relative Date Resolution | Relative expressions like 'yesterday' or 'last quarter' are resolved to absolute dates with a [RESOLUTION_NOTE] explaining the reference point | Relative dates are passed through as literal text or resolved incorrectly | Provide inputs with known relative dates and a fixed reference timestamp; verify absolute output and note |
Cross-Field Consistency | Related date pairs such as [EFFECTIVE_DATE] and [EXPIRATION_DATE] satisfy logical ordering where applicable | Effective date is after expiration date without a flag or note | Assert that when both fields are present and non-null, effective_date <= expiration_date unless an override note is present |
Confidence Score Threshold | Every extracted date includes a [CONFIDENCE] score between 0.0 and 1.0; scores below 0.7 trigger a [REVIEW_FLAG] | Confidence scores are missing, out of range, or uniformly high despite ambiguous input | Provide inputs with varying extraction difficulty and assert confidence distribution is reasonable and flags fire below threshold |
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
Start with the base prompt but relax strict schema enforcement. Use a simpler output contract—flat JSON with date fields and source attribution, no nested ambiguity records. Accept string dates without requiring ISO-8601 conversion in the prompt itself; handle normalization in post-processing code.
codeExtract all dates from [DOCUMENT_TEXT]. Return JSON: {"dates": [{"value": "string", "source_field": "string", "type_guess": "effective|signature|revision|metadata|unknown"}]}
Watch for
- Multiple date formats in the same document causing inconsistent
valuestrings source_fieldhallucinations when the document has no explicit field labels- Missing timezone assumptions on timestamps—decide a default early
- No confidence signals, so ambiguous dates (e.g., "01/02/2025") pass through silently

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