Skip to content
Back to skills

Sql Date Time

ASecurity

Store, compare, and bucket timestamps with explicit time zones so reports do not drift by a day and ranges do not miss rows. Use when filtering by date, grouping by period, or storing an event time.

  • 7 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
ai-agentssqldatabase

Security analysis

A100/100

Scanned September 5, 2026

npx -y skills add Amey-Thakur/AI-SKILLS --skill sql-date-time --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sql Date Time?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sql Date Time
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/amey-thakur-sql-date-time/badge)](https://www.skillsdirectory.com/skills/amey-thakur-sql-date-time)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sql-date-time
description: Store, compare, and bucket timestamps with explicit time zones so reports do not drift by a day and ranges do not miss rows. Use when filtering by date, grouping by period, or storing an event time.
---

# SQL date and time

Time bugs are quiet: a report is off by a day for some users, a range
misses the last hour, a daily job double counts around a clock change.
Nearly all of them come from an implicit time zone or a boundary written
with BETWEEN.

## Method

1. **Store instants in UTC with a time zone aware type.** A naive
   timestamp is ambiguous the moment two regions use it, and the
   ambiguity is unrecoverable later.
2. **Convert for display and grouping only.** A daily report means days
   in someone's local zone, so convert at the point of bucketing and
   record which zone was used.
3. **Write half-open ranges.** Greater than or equal to the start and
   strictly less than the end. BETWEEN on timestamps either misses the
   final fraction of a second or double counts a boundary row.
4. **Beware date arithmetic across clock changes.** Adding a day is not
   always adding twenty-four hours where daylight saving applies, and
   the two operations are different functions.
5. **Keep the filter column bare.** Wrapping the column in a function
   usually prevents index use, so transform the bounds instead of the
   column (see sql-optimization).
6. **Separate event time from ingestion time.** When something happened
   and when you recorded it are different questions, and analytics
   eventually needs both (see batch-vs-streaming).

## Boundaries

- Time zone rules change by legislation, so correctness depends on an
  up-to-date zone database rather than arithmetic.
- Date-only values are not instants; treating a birth date as a
  timestamp introduces a zone question that should not exist.
- Precision differs between engines and can silently truncate on insert.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…