webfilteringdatabase.com
Home Find Your Solution
Features
Domain Categorization API Real-Time Classification 59 Filtering Categories Offline Database (100M) ML Classification Content Classification
Industries
K-12 Schools Corporate Healthcare Government ISPs
Tools
Domain Lookup Bulk Categorization Category Explorer
Resources
Pricing API Documentation Login / Sign Up
How-To Guide

How to Redact Dates and Date of Birth

Learn how to automatically detect and redact dates, birth dates, and temporal information from text and documents. Protect age-related PII while preserving data utility through generalization and shifting techniques.

10 min read Code examples included Updated Jan 2025
In This Guide Overview Why Redact Dates Quick Start Date Formats Techniques Code Examples Best Practices FAQ
Overview

A Birth Date Is Almost a Fingerprint

Dates, particularly dates of birth, are critical personally identifiable information (PII) that can directly identify individuals or significantly narrow down their identity when combined with other data.

Birth dates are used for identity verification, age-based profiling, and when combined with location data, can uniquely identify over 87% of the US population according to research.

99.3% Accuracy on Virtually Any Format

Anonymization API uses sophisticated pattern recognition to detect dates in virtually any format with 99.3% accuracy.

  • Our system recognizes full dates, partial dates (month/year), relative dates ("last Tuesday"), written dates ("March fifteenth"), and dates in 40+ international formats.
  • Context analysis distinguishes birth dates from other types of dates.

Before Anonymization

Patient John Smith, DOB: 03/15/1985, visited on January 20, 2025

After Anonymization

Patient John Smith, DOB: [DATE_OF_BIRTH], visited on [DATE]

Whether you're processing medical records, customer databases, HR files, or research data, our API ensures that date information is properly anonymized while preserving temporal relationships and analytical value. We support multiple techniques from complete redaction to date shifting that maintains relative time intervals.

40+ Formats

US, European, ISO, and international date formats

DOB Detection

Context-aware birth date identification

Date Shifting

Preserve temporal relationships while anonymizing

Why Redact Dates

Highly Identifying, Often Overlooked

Dates present unique privacy challenges because they can be highly identifying, especially dates of birth. A birth date combined with just gender and 5-digit zip code can uniquely identify 87% of Americans. Additionally, dates often reveal sensitive information about life events, medical conditions, or activities.

HIPAA (Healthcare)

Dates directly related to an individual (birth date, admission date, discharge date, death date) are Protected Health Information. For Safe Harbor de-identification, only year may be retained. For individuals over 89, even the year must be aggregated.

GDPR (Europe)

Birth dates are personal data. When combined with other data, even partial dates may require protection. Age-based processing may require explicit consent.

COPPA (Children)

Collection of birth dates from children under 13 requires parental consent. Date information that reveals a child's age triggers COPPA requirements.

FCRA (Credit)

Birth dates in credit reports are regulated information with restricted access.

FERPA (Education)

Student birth dates in education records require protection.

Age Discrimination Laws

Birth dates in employment contexts can create legal liability under ADEA and similar laws.

Types of Sensitive Date Information

  • Date of Birth (DOB): The most identifying date type - used for identity verification, age calculation, and profiling.
  • Medical Dates: Admission, discharge, procedure, and treatment dates reveal health information.
  • Transaction Dates: Purchase, payment, and activity timestamps can reveal behavior patterns.

 

  • Employment Dates: Hire dates, termination dates, and leave dates reveal work history.
  • Event Dates: Marriage, divorce, incident, and milestone dates reveal life events.
  • Death Dates: Date of death is HIPAA PHI and may be sensitive for surviving family.
Quick Start

Redact Dates in a Few Lines of Code

Get started with date redaction in just a few lines of code. This example demonstrates the simplest way to detect and redact dates from text using our API.

from anonymization import Client

client = Client(api_key="your_api_key")

result = client.anonymize(
    text="Patient born 03/15/1985, appointment on 2025-01-20",
    entity_types=["DATE", "DATE_OF_BIRTH"]
)

print(result.anonymized_text)
# Output: Patient born [DATE_OF_BIRTH], appointment on [DATE]
const { AnonymizationClient } = require('@anonymization/api');

const client = new AnonymizationClient('your_api_key');

const result = await client.anonymize({
    text: "Patient born 03/15/1985, appointment on 2025-01-20",
    entityTypes: ["DATE", "DATE_OF_BIRTH"]
});

console.log(result.anonymizedText);
// Output: Patient born [DATE_OF_BIRTH], appointment on [DATE]
curl -X POST https://api.anonymizationapi.com/v2/anonymize \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Patient born 03/15/1985, appointment on 2025-01-20",
    "entity_types": ["DATE", "DATE_OF_BIRTH"]
  }'

The API response includes parsed date information and classification details:

{
  "anonymized_text": "Patient born [DATE_OF_BIRTH], appointment on [DATE]",
  "entities": [
    {
      "type": "DATE_OF_BIRTH",
      "text": "03/15/1985",
      "start": 13,
      "end": 23,
      "confidence": 0.98,
      "metadata": {
        "parsed_date": "1985-03-15",
        "format": "MM/DD/YYYY",
        "age": 39
      }
    },
    {
      "type": "DATE",
      "text": "2025-01-20",
      "start": 40,
      "end": 50,
      "confidence": 0.99,
      "metadata": {
        "parsed_date": "2025-01-20",
        "format": "YYYY-MM-DD"
      }
    }
  ]
}
Date Formats

Numeric, Written, and Relative Dates

Dates appear in countless formats depending on locale, system, and writing style. Our API recognizes and normalizes all common variations.

Numeric Formats
03/15/1985 (US: MM/DD/YYYY) 15/03/1985 (European: DD/MM/YYYY) 1985-03-15 (ISO 8601) 03-15-85 (Short year) 3/15/85 (Without leading zeros) 03.15.1985 (Dot separator) 19850315 (Compact)
Written Formats
March 15, 1985 15 March 1985 Mar 15, 1985 March fifteenth, nineteen eighty-five 15th of March, 1985 March 1985 Spring 1985
Relative Dates
yesterday last Tuesday two weeks ago next month in 3 days the previous year

Date Components

The API can detect and handle partial dates and individual components:

# Detect full dates (default)
result = client.anonymize(text, entity_types=["DATE"])

# Detect specific date types
result = client.anonymize(text, entity_types=[
    "DATE",            # Full dates
    "DATE_OF_BIRTH",  # Birth dates (contextual)
    "YEAR",           # Year only (e.g., "born in 1985")
    "MONTH_YEAR",     # Month and year (e.g., "March 2025")
    "AGE"             # Age mentions (e.g., "45 years old")
])

# Specify expected date format for ambiguous dates
result = client.anonymize(
    text="Date: 03/04/2025",  # Is this March 4 or April 3?
    entity_types=["DATE"],
    options={"date_format": "MM/DD/YYYY"}  # US format
)
Anonymization Techniques

Six Ways to Anonymize a Date

Choose the appropriate date anonymization technique based on your privacy requirements and analytical needs.

1

Full Redaction (Default)

Completely replaces the date with a placeholder. Maximum privacy protection.

Born on March 15, 1985
Born on [DATE]
2

Year-Only Generalization

Keeps only the year, removing month and day. Meets HIPAA Safe Harbor requirements.

Born on March 15, 1985
Born in 1985
3

Age Conversion

Converts birth dates to ages. Useful when age is needed for analysis but exact birth date is not.

DOB: March 15, 1985
Age: 39 years
4

Age Range Generalization

Converts to age ranges for additional protection. Useful for demographic analysis.

DOB: March 15, 1985
Age: 35-44
5

Date Shifting

Shifts all dates by a random but consistent offset. Preserves temporal relationships between events while hiding actual dates.

Admitted: Jan 15, 2025. Discharged: Jan 20, 2025.
Admitted: Mar 22, 2025. Discharged: Mar 27, 2025.
6

Month/Year Preservation

Keeps month and year, removes the specific day. Balances privacy with temporal precision.

Event on March 15, 2025
Event in March 2025
# Full redaction (default)
result = client.anonymize(text, entity_types=["DATE"], mode="redact")

# Year-only generalization (HIPAA compliant)
result = client.anonymize(text, entity_types=["DATE"], mode="generalize",
    options={"date_keep": "year"})

# Convert DOB to age
result = client.anonymize(text, entity_types=["DATE_OF_BIRTH"], mode="generalize",
    options={"dob_to_age": True})

# Convert to age ranges (10-year buckets)
result = client.anonymize(text, entity_types=["DATE_OF_BIRTH"], mode="generalize",
    options={"dob_to_age_range": 10})

# Date shifting with consistent offset per session
result = client.anonymize(text, entity_types=["DATE"], mode="shift",
    options={"date_shift_range": 365},  # Max shift of 1 year
    session_id="patient-123")  # Same shift for same patient

# Keep month and year
result = client.anonymize(text, entity_types=["DATE"], mode="generalize",
    options={"date_keep": "month_year"})
Detection at a Glance

Temporal Privacy by the Numbers

99.3%Date detection accuracy on benchmark datasets
40+International date formats recognized
87%Of the US population identifiable by DOB + gender + zip
90+HIPAA age bracket requiring aggregation
Research shows that date of birth is one of the most powerful quasi-identifiers. When building anonymized datasets, consider that even approximate dates can enable re-identification attacks when combined with other fields.
Code Examples

Practical Recipes for Date Redaction

HIPAA-Compliant Date Redaction

Process medical records with Safe Harbor compliant date handling:

medical_record = """
Patient: John Smith
DOB: March 15, 1985
Admission Date: January 20, 2025
Procedure Date: January 22, 2025
Discharge Date: January 25, 2025
Next Appointment: February 15, 2025
"""

# HIPAA Safe Harbor: Keep only year, aggregate ages over 89
result = client.anonymize(
    text=medical_record,
    entity_types=["PERSON", "DATE", "DATE_OF_BIRTH"],
    mode="generalize",
    options={
        "date_keep": "year",
        "hipaa_age_90": True  # Aggregate ages 90+ as "90+"
    }
)

print(result.anonymized_text)

Date Shifting for Research Data

Maintain temporal relationships while anonymizing dates:

# Process multiple records for the same patient with consistent shift
patient_records = [
    "Visit 1: 2025-01-15, BP 120/80",
    "Visit 2: 2025-02-20, BP 118/78",
    "Visit 3: 2025-04-10, BP 122/82"
]

# Same session_id ensures consistent date shift across records
results = client.batch_anonymize(
    items=[{"text": r, "session_id": "patient-001"} for r in patient_records],
    entity_types=["DATE"],
    mode="shift",
    options={"date_shift_range": 180}  # +/- 6 months
)

# Time intervals between visits are preserved!
# e.g., 36 days between visit 1 and 2 remains 36 days

Age-Based Analysis

Convert birth dates to ages or age ranges for demographic analysis:

customer_data = [
    "Customer A, DOB: 1985-03-15",
    "Customer B, born January 2, 1970",
    "Customer C, birthdate 06/20/1992"
]

# Convert to age ranges for demographic analysis
results = client.batch_anonymize(
    items=[{"text": c} for c in customer_data],
    entity_types=["DATE_OF_BIRTH"],
    mode="generalize",
    options={"dob_to_age_range": 10}  # 10-year buckets
)

for r in results:
    print(r.anonymized_text)
# Customer A, Age: 35-44
# Customer B, Age: 55-64
# Customer C, Age: 25-34

Selective Date Redaction

Redact some dates while preserving others:

# Only redact birth dates, keep other dates
result = client.anonymize(
    text="DOB: 03/15/1985, hired on 01/10/2020, contract ends 12/31/2025",
    entity_types=["DATE_OF_BIRTH"]  # Only birth dates
)
# Output: DOB: [DATE_OF_BIRTH], hired on 01/10/2020, contract ends 12/31/2025

# Redact dates within a specific range
result = client.anonymize(
    text=text,
    entity_types=["DATE"],
    options={
        "date_before": "2020-01-01",  # Only dates before 2020
    }
)
Best Practices

Get Date Redaction Right in Production

Treat Birth Dates with Extra Care

Birth dates are more identifying than general dates and require stricter handling:

# Apply stricter rules to DOB than general dates
result = client.anonymize(
    text=text,
    entity_types=["DATE", "DATE_OF_BIRTH"],
    options={
        "date_keep": "month_year",  # General dates: keep month/year
        "dob_mode": "year_only"     # DOB: keep year only
    }
)

Handle Elderly Ages Under HIPAA

HIPAA requires special handling for ages over 89:

# HIPAA compliant: aggregate 90+ ages
result = client.anonymize(
    text="Patient born 1930, admitted today",
    entity_types=["DATE_OF_BIRTH"],
    mode="generalize",
    options={
        "dob_to_age": True,
        "hipaa_age_90": True  # Show as "90+" for 90+ years
    }
)
# Output: Patient age 90+, admitted today

Use Date Shifting for Longitudinal Data

When analyzing data over time, date shifting preserves patterns while hiding actual dates:

# Date shifting maintains:
# - Days between events
# - Weekday patterns (optional)
# - Seasonal patterns (with small shift range)

result = client.anonymize(
    text=text,
    entity_types=["DATE"],
    mode="shift",
    options={
        "date_shift_range": 30,     # +/- 30 days
        "preserve_weekday": True,   # Keep same day of week
        "preserve_month": True      # Keep within same month
    },
    session_id="study-participant-001"
)

Consider Context for Date Detection

Enable context analysis to properly classify date types:

# Context helps distinguish:
# - "DOB: 03/15/1985" -> DATE_OF_BIRTH
# - "Report date: 03/15/1985" -> DATE
# - "Invoice #03151985" -> Not a date

result = client.anonymize(
    text=text,
    entity_types=["DATE", "DATE_OF_BIRTH"],
    options={"use_context": True}
)

Handle Ambiguous Date Formats

Specify the expected date format when processing data from known sources:

Caution: The date "03/04/2025" is March 4th in US format but April 3rd in European format. Always specify the expected format when processing data from a known source to avoid misinterpretation.

FAQ

Frequently Asked Questions

How accurate is date detection?

Our date detection achieves 99.3% accuracy on benchmark datasets covering 40+ formats. Accuracy is highest for standard numeric formats (99.7%) and slightly lower for written dates and relative expressions. Context analysis significantly improves birth date classification.

How do I handle dates in different languages?

The API supports date detection in multiple languages including month names in Spanish, French, German, and more. Specify the language for better accuracy: options={"language": "es"}. Written dates like "quince de marzo" are properly detected.

What happens with invalid or partial dates?

The API attempts to parse and validate dates. Invalid dates (like February 30th) are flagged with lower confidence. Partial dates (just month/year or just year) are detected with the appropriate entity type (MONTH_YEAR, YEAR).

Can I detect ages without birth dates?

Yes, use entity_types=["AGE"] to detect age mentions like "45 years old", "a 30-year-old patient", or "aged 65". These can be generalized to age ranges just like birth dates.

How does date shifting work across time zones?

Date shifting operates on dates without time zone consideration by default. For timestamps with time zones, the shift is applied consistently. You can specify options={"preserve_timezone": True} to maintain original time zone information.

Can I preserve relative dates?

Relative dates like "yesterday" or "last week" can be optionally preserved since they don't identify specific dates. Use options={"preserve_relative_dates": True}. Note that relative dates may become identifying when combined with document timestamps.

What about timestamps with time components?

Full timestamps (date + time) are detected and handled. You can redact only the date portion, only the time portion, or both. Use entity_types=["DATE", "TIME", "DATETIME"] for granular control.

Related Guides

Keep Building Your Redaction Pipeline

Start Redacting Dates Today

Protect date information with 99.3% accuracy. Support for 40+ formats, date shifting, and HIPAA-compliant options.

Get Started Free