Inferensys

Prompt

Date Field Imputation Prompt for Missing Values

A practical prompt playbook for using Date Field Imputation Prompt for Missing Values 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 the job, reader, and constraints for the Date Field Imputation Prompt for Missing Values.

This prompt is designed for data quality engineers and ML pipeline operators who need to fill missing date fields in structured or semi-structured records. The job-to-be-done is not simple null replacement; it is evidence-based imputation that uses contextual clues from surrounding records, related fields, or temporal sequences to infer the most probable date. The ideal user has a dataset with partial temporal completeness—some records have dates, others don't—and needs a programmatic, auditable way to fill gaps before the data enters a downstream system like a reporting database, a forecasting model, or a scheduling engine. Required context includes the record with the missing date, a window of surrounding records or related fields that may contain temporal signals, and a clear definition of the target date field's meaning (e.g., order_date, ship_date, event_timestamp).

Do not use this prompt when the missing date is the primary key for a compliance or legal record where imputation would create audit risk without human review. It is also inappropriate for datasets where missingness is non-random and the absence of a date carries signal—for example, a missing close_date in a CRM might mean the deal is still open, and imputing a date would corrupt that signal. In those cases, the correct behavior is to leave the field null and handle missingness in the application layer. This prompt is also not a substitute for fixing the data collection process that produces the missing values; it is a repair step for pipelines that must tolerate incomplete upstream data.

Before deploying this prompt, prepare a holdout dataset with known dates that you artificially mask to evaluate imputation accuracy. The prompt's uncertainty score is only useful if you calibrate it against real error distributions. Start with a strict threshold: if the uncertainty score exceeds 0.3, route the record for human review rather than accepting the imputed value. As you gather production data on imputation accuracy, you can adjust this threshold or introduce automated acceptance for low-uncertainty, high-confidence cases. Never ship this prompt without a monitoring dashboard that tracks imputation rate, uncertainty distribution, and downstream impact on metrics that depend on temporal accuracy.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Date Field Imputation Prompt works reliably and where it introduces unacceptable risk. Use this guide to decide whether to deploy the prompt, add a human review step, or choose a different approach entirely.

01

Good Fit: Context-Rich Record Gaps

Use when: A single date field is missing from an otherwise complete record, and surrounding fields (e.g., related timestamps, status changes, or sequential IDs) provide strong temporal clues. Guardrail: Require at least two correlated temporal fields before trusting the imputation; single-field inference is too brittle.

02

Bad Fit: Sparse or No Context

Avoid when: The record has no related timestamps, no sequential neighbors, and no descriptive text that implies a date. The model will hallucinate a plausible but fabricated value. Guardrail: Implement a pre-check that counts available temporal signals and refuses imputation if the count is below a configurable threshold.

03

Required Inputs

What you must provide: The target record with the missing field, at least two surrounding records with valid dates, and the schema definition for the date field (format, timezone expectation, and business constraints like 'must be in the past'). Guardrail: Validate all input records before imputation—garbage timestamps in surrounding records produce garbage imputations.

04

Operational Risk: Silent Hallucination

What to watch: The model returns a high-confidence imputation with a plausible method description, but the date is fabricated because the context was insufficient. This is the most dangerous failure mode because it passes casual review. Guardrail: Always run imputed dates through a holdout validation set with known missing values, and flag any imputation where the uncertainty score exceeds your pipeline's tolerance.

05

When to Escalate Instead

What to watch: The imputation uncertainty score is high, the method relies on a single weak signal, or the imputed date would trigger a business rule violation (e.g., a shipment date before the order date). Guardrail: Route high-uncertainty records to a human review queue with the imputation rationale and source fields displayed, rather than silently accepting the model's best guess.

06

Downstream Dependency Risk

What to watch: Imputed dates flow into reporting pipelines, billing calculations, or compliance audits where accuracy is mandatory. A single bad imputation can corrupt aggregates or trigger audit findings. Guardrail: Tag all imputed records with an imputation_method and uncertainty_score field, and exclude low-confidence imputations from compliance-critical reports until reviewed.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for imputing missing date fields using contextual clues from surrounding records.

This section provides a copy-ready prompt template for the Date Field Imputation task. The template is designed to be dropped into an AI harness where the application layer supplies the record context, the target field, and the expected output schema. Every placeholder is marked with square brackets so you can wire in your own data, constraints, and evaluation criteria without modifying the core instruction structure. The prompt instructs the model to return not only the imputed date but also the method used, the source fields that informed the decision, and an uncertainty score—making the output auditable and testable against holdout datasets.

text
You are a temporal data imputation specialist. Your task is to fill a missing date field in a record by reasoning over contextual clues from surrounding fields and related records.

## INPUT
Record with missing field: [RECORD_JSON]
Target field to impute: [TARGET_FIELD_NAME]
Surrounding records for context (optional): [SURROUNDING_RECORDS_JSON_ARRAY]
Domain context (optional): [DOMAIN_CONTEXT]

## CONSTRAINTS
- Do not invent dates that cannot be inferred from the provided context.
- If multiple plausible dates exist, return the most likely one and explain alternatives in the rationale.
- Respect any business rules provided in [BUSINESS_RULES].
- If no reasonable imputation is possible, set the imputed value to null and set the uncertainty score to 1.0.
- Prefer imputation methods in this order: direct derivation from related fields, interpolation from surrounding records, domain-typical defaults, statistical imputation.

## OUTPUT_SCHEMA
Return a JSON object with exactly these fields:
{
  "imputed_value": "ISO 8601 date string or null",
  "imputation_method": "derivation | interpolation | domain_default | statistical | none",
  "source_fields_used": ["list of field names from the record or surrounding records"],
  "uncertainty_score": 0.0-1.0,
  "rationale": "Brief explanation of how the date was determined or why imputation was not possible"
}

## EXAMPLES
[FEW_SHOT_EXAMPLES]

## RISK_LEVEL
[RISK_LEVEL]

To adapt this template for your pipeline, replace each bracketed placeholder with concrete values from your application context. [RECORD_JSON] should contain the full record with the missing date field. [SURROUNDING_RECORDS_JSON_ARRAY] is optional but critical for interpolation-based imputation—supply temporally adjacent records when available. [DOMAIN_CONTEXT] can include information like 'these are e-commerce order records' or 'dates represent patient visit timestamps' to help the model select appropriate defaults. [BUSINESS_RULES] should encode constraints such as 'dates must be in the past' or 'shipment dates cannot precede order dates.' [FEW_SHOT_EXAMPLES] should include 2-4 examples covering derivation, interpolation, and no-imputation-possible scenarios. Set [RISK_LEVEL] to 'low', 'medium', or 'high' to adjust the model's conservatism—high-risk domains should bias toward null imputation when uncertainty is elevated. After adapting the template, validate outputs against a holdout dataset where you have artificially removed known dates and can measure imputation accuracy, mean absolute error, and the calibration of uncertainty scores.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Date Field Imputation Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to check that the input is fit for purpose.

PlaceholderPurposeExampleValidation Notes

[TARGET_RECORD]

The record with the missing date field that needs imputation

{"event": "purchase", "date": null, "customer_id": "C402"}

Must be valid JSON. The field to impute must be present with a null, empty string, or missing-key indicator. Reject if record is empty or unparseable.

[SURROUNDING_RECORDS]

Context records before and after the target record in sequence, used to infer the missing date

[{"event": "login", "date": "2025-03-14T09:12:00Z"}, {"event": "logout", "date": "2025-03-14T10:45:00Z"}]

Must be a valid JSON array with at least one record containing a date. Each record must have the same schema as [TARGET_RECORD]. Reject if array is empty or all dates are null.

[DATE_FIELD_NAME]

The name of the date field to impute in the target record

purchase_date

Must match exactly the key name in [TARGET_RECORD]. Case-sensitive. Reject if field name is not found in the record schema.

[RELATED_FIELDS]

Other fields in the record that may contain temporal clues for imputation

["last_login", "account_created", "subscription_expiry"]

Must be a JSON array of field names present in the record schema. Null allowed if no related fields exist. Warn if referenced fields are also null or missing.

[BUSINESS_RULES]

Constraints that the imputed date must satisfy

["date must be after account_created", "date must be within business hours 08:00-18:00 UTC"]

Must be a JSON array of rule strings. Each rule must reference fields in the schema. Reject rules that reference non-existent fields. Null allowed if no business rules apply.

[OUTPUT_SCHEMA]

Expected structure for the imputation result

{"imputed_date": "ISO 8601", "method": "string", "source_fields": ["string"], "confidence": 0.0-1.0}

Must be a valid JSON Schema or example object. The schema must include fields for the imputed value, method, source fields used, and a confidence score. Reject if schema is missing required output fields.

[HOLDOUT_EXAMPLES]

Optional few-shot examples with known missing dates for in-context calibration

[{"record": {...}, "missing_date": "2025-03-15", "method": "interpolation"}]

Must be a JSON array of objects, each with a record, the known missing date, and the imputation method. Null allowed. If provided, each example must include the ground-truth date for the prompt to use as a reference pattern.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Date Field Imputation Prompt into a data pipeline with validation, retries, logging, and human review gates.

Integrating the Date Field Imputation Prompt into a production pipeline requires treating it as a deterministic repair step with well-defined inputs, outputs, and failure modes. The prompt expects a structured context object containing the record with the missing date field, surrounding records for temporal context, and any business rules that constrain valid date ranges. Before calling the model, the harness should assemble this context programmatically—querying adjacent records by primary key or timestamp, injecting schema metadata about which fields are nullable, and attaching domain constraints such as 'order_date must be after customer_creation_date'. The harness should never pass raw database rows directly; instead, it should serialize only the fields relevant to imputation, explicitly marking the target field as null and labeling each provided field with its semantic meaning.

After the model returns, the harness must validate the output against a strict schema before accepting the imputed value. The expected response shape includes: imputed_date (ISO 8601 string), imputation_method (enum: interpolation, propagation, default_rule, contextual_inference), source_fields_used (array of field names), and uncertainty_score (float 0.0–1.0). A JSON Schema validator should reject responses missing required fields, containing out-of-range scores, or returning dates that violate injected business rules. If validation fails, the harness should retry once with the validation error message appended to the prompt as feedback. After two failures, the record should be routed to a dead-letter queue for human review rather than silently accepting a bad imputation. Log every imputation attempt with the record ID, model version, prompt hash, output, validation result, and latency for downstream audit and drift analysis.

Model choice matters here. This task benefits from models with strong instruction-following and structured output capabilities. For high-throughput pipelines, consider using a smaller fine-tuned model if you have a labeled dataset of known missing-value resolutions. For low-volume, high-accuracy use cases, a frontier model with strict JSON mode enabled is appropriate. If your pipeline processes records in batches, avoid sending more than 5–10 records per call—larger contexts increase the risk of the model mixing up record boundaries or hallucinating relationships. Always include a [RISK_LEVEL] parameter in the prompt: set it to high when imputing dates for compliance, financial, or clinical records, which should trigger mandatory human review regardless of confidence score. For low risk records, auto-accept imputations with uncertainty below 0.3 and log the rest for sampling. Never use imputed dates as ground truth for downstream model training without flagging them as synthetic.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structure, types, and validation rules for the imputed date response. Use this contract to parse the model output, validate correctness, and integrate into downstream pipelines.

Field or ElementType or FormatRequiredValidation Rule

imputed_date

string (ISO 8601 YYYY-MM-DD)

Must parse as a valid date. Year must be within the range specified in [YEAR_BOUNDS]. Day must be valid for the given month.

imputation_method

string (enum)

Must be one of: 'carry_forward', 'carry_backward', 'linear_interpolation', 'field_derivation', 'static_default', 'contextual_inference'. No other values allowed.

source_fields_used

array of strings

Each string must match a field name provided in [AVAILABLE_FIELDS]. Array must not be empty unless method is 'static_default'.

uncertainty_score

number (float)

Must be a value between 0.0 and 1.0 inclusive. Higher scores indicate lower confidence. Score of 1.0 requires the 'needs_review' flag to be set to true.

imputation_rationale

string

Must be a non-empty string explaining the logic, including the specific records or rules used. Must not exceed 500 characters.

needs_review

boolean

Must be true if uncertainty_score >= [REVIEW_THRESHOLD] or if source_fields_used is empty. Otherwise, must be false.

conflicting_evidence

array of objects

If present, each object must contain a 'field' (string) and 'value' (string) describing the conflicting data point. Required if the model identifies contradictory temporal clues.

PRACTICAL GUARDRAILS

Common Failure Modes

Date imputation is inherently uncertain. These are the most common ways the prompt breaks in production and how to prevent silent data corruption.

01

Overconfident Imputation Without Uncertainty Signaling

What to watch: The model fills a missing end_date with a precise value but omits the required uncertainty_score or imputation_method, making the output indistinguishable from ground truth. Guardrail: Add a strict output schema validator that rejects any imputed record missing the uncertainty_score field. If the score is below the configured threshold, route the record to a human review queue instead of the downstream pipeline.

02

Context Window Starvation for Surrounding Records

What to watch: When imputing a missing date in a sparse sequence, the model lacks sufficient surrounding records to detect a pattern and defaults to a naive midpoint or the dataset's mean date. Guardrail: Implement a pre-retrieval step that packs the prompt with a fixed number of chronologically adjacent records. If the record density falls below a minimum threshold, instruct the model to return null for the imputed date rather than guessing.

03

Logical Inconsistency with Related Fields

What to watch: The model imputes a ship_date that falls before the order_date or a birth_date after a death_date, violating basic temporal logic. Guardrail: Add a post-processing consistency check that validates the imputed date against all other timestamp fields in the record. Use a deterministic rule engine for hard constraints and flag violations for manual review before the record enters the data warehouse.

04

Silent Format Drift in the Imputed Output

What to watch: The prompt specifies ISO 8601 output, but under complex contextual pressure the model reverts to MM/DD/YYYY or a Unix timestamp, breaking downstream parsers. Guardrail: Apply a strict regex or schema validator on the imputed_date field immediately after generation. If the format check fails, use a repair prompt or a deterministic formatting library to coerce the value before retrying the imputation.

05

Hallucinated Source Fields for the Imputation Rationale

What to watch: The model correctly imputes a date but fabricates the source_fields_used explanation, claiming it used a created_at field that doesn't exist in the input schema. Guardrail: Cross-reference the source_fields_used array in the output against the actual input schema. If any field is not present in the provided record, discard the rationale and flag the record for a traceability audit.

06

Catastrophic Forgetting of the Imputation Policy

What to watch: The system prompt instructs the model to prefer median imputation for gaps under 7 days, but a long few-shot example or complex user context causes the model to silently switch to a linear_interpolation strategy. Guardrail: Place the imputation strategy instruction at the very end of the system prompt and repeat it as a final REMEMBER: directive. Validate the imputation_method field in the output against the allowed strategy list for the specific data domain.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Date Field Imputation Prompt before shipping. Each criterion targets a specific failure mode observed in temporal imputation tasks. Run these checks against a holdout dataset with known missing values and ground-truth dates.

CriterionPass StandardFailure SignalTest Method

Imputation Method Attribution

Every imputed date includes a non-null method field from the allowed enum: [CONTEXTUAL_INFERENCE], [DEFAULT_VALUE], [INTERPOLATION], [EXTRAPOLATION], [COPY_FROM_RELATED_RECORD]

Missing method field, null value, or method not in allowed enum

Schema validation on output; assert method field is present and enum-valid for all imputed records

Source Field Traceability

Every imputed date includes a non-empty array of source field names used for imputation; null allowed only when method is [DEFAULT_VALUE]

Empty source array, missing source field, or source fields that do not exist in the input schema

Cross-reference source field names against input record schema; assert array length > 0 for all methods except [DEFAULT_VALUE]

Uncertainty Score Range

Every imputed date includes an uncertainty score between 0.0 and 1.0 inclusive; score must be a float, not a string or integer

Score outside 0.0-1.0 range, score is null, score is a string like 'low', or score is missing

Parse output as JSON; assert uncertainty_score is float and 0.0 <= score <= 1.0 for all records

Output Date Format Compliance

Every imputed date string conforms to ISO 8601 YYYY-MM-DD format; no timestamps, no timezone offsets, no slashes or locale-specific separators

Date contains time component, uses MM/DD/YYYY or DD/MM/YYYY format, includes timezone, or is unparseable

Regex match against ^\d{4}-\d{2}-\d{2}$ for all imputed date strings; reject any non-matching values

Non-Imputation of Present Values

Records where the target date field is already populated are returned unchanged; no imputation method or uncertainty score applied to these records

Present dates are overwritten, method field appears on non-imputed records, or uncertainty score is non-null for present values

Compare input records with populated dates to output; assert date value unchanged and imputation fields are null or absent

Contextual Plausibility

Imputed dates are temporally plausible given surrounding record context; e.g., an order date must not precede a customer creation date if both are available

Imputed date violates known temporal ordering constraints from related fields in the same or adjacent records

Run consistency checks: assert order_date >= customer_created_date, shipment_date >= order_date, etc. using ground-truth rules

Holdout Accuracy Threshold

Imputed dates on holdout records match ground truth within ±1 day for at least 85% of records where uncertainty score < 0.5

Accuracy below 85% on low-uncertainty predictions, or high-uncertainty predictions are systematically wrong rather than flagged

Compare imputed dates against known ground truth; compute exact-match and within-1-day accuracy stratified by uncertainty score buckets

Null Handling for Impossible Cases

When no contextual clues exist and no default rule applies, the prompt returns null for the imputed date with method [UNABLE_TO_IMPUTE] and uncertainty_score 1.0

Prompt hallucinates a plausible but unsupported date, or returns a date with uncertainty_score 1.0 and a method other than [UNABLE_TO_IMPUTE]

Test with records stripped of all contextual fields; assert imputed_date is null, method is [UNABLE_TO_IMPUTE], uncertainty_score is 1.0

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small labeled dataset of records with known missing dates. Use the prompt to impute missing values and compare against ground truth. Keep the output schema simple: { "imputed_date": "YYYY-MM-DD", "method": "string", "source_fields": ["string"], "uncertainty": "low|medium|high" }. Run 20-30 examples manually before adding validation logic.

Watch for

  • The model defaulting to today's date when context is thin
  • Overconfidence on records with only one weak signal
  • Imputing dates that violate temporal ordering with surrounding records
  • Not flagging uncertainty: high when it should
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.