Seed Data with Realistic Date and Timestamp Ranges
Generate seed data with realistic TIMESTAMP, DATETIME, and DATE values spanning a configurable range. Learn how date columns are handled.
Detailed Explanation
Date and Timestamp Generation
Date and time columns are critical for testing time-based queries, sorting, and display formatting. The seed generator produces dates within a realistic range to make test data behave like production data.
Supported Date Types
| SQL Type | Example Output |
|---|---|
DATE |
'2023-07-15' |
TIMESTAMP |
'2022-11-03 14:27:38' |
DATETIME |
'2024-02-19 09:45:12' |
TIMESTAMPTZ |
'2021-08-22 18:03:51' |
TIME |
'14:27:38' |
Date Range
All generated dates fall within the range 2020–2025. This range is wide enough to test date filtering and sorting, while being recent enough to look realistic in a modern application. Days are capped at 28 to avoid invalid dates in February.
Column Name Heuristics for Dates
The generator does not apply date-specific name heuristics beyond what the SQL type already provides. Columns named created_at, updated_at, birth_date, or expires_on all receive dates based on their declared SQL type (TIMESTAMP, DATE, etc.).
Testing Time-Based Features
Realistic timestamps let you verify:
- Sorting: "newest first" and "oldest first" ordering
- Filtering: date range pickers, "last 30 days" filters
- Display: relative time formatting ("3 months ago")
- Pagination: cursor-based pagination using timestamps
- Timezone handling: how your app converts between UTC and local time
Null Handling for Dates
If a date column is nullable (no NOT NULL constraint), approximately 10% of rows will receive NULL instead of a date. This helps test how your UI handles missing dates in tables, cards, and detail views.
Use Case
You are building an analytics dashboard that filters and groups records by date. You need seed data with timestamps spread across several years so that date range pickers, monthly aggregations, and time-series charts display meaningful results during development.