Skip to content
Skills Library
Data & analytics · Building & coding

sql-date-time

/sql-date-time

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.

Repository
AI-SKILLS ↗
Licence
MIT
Last repository change
05.09.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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.

Original author 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.

How it works

  1. Method
  2. Boundaries
Original SKILL.md headings · 37 lines, 273 words
SKILL.md preview
---
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.

Versions

The database has no other skills named sql-date-time.

Database snapshot: 13.11.2026 · package version b3e13192217c (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95storing-data
    How to store application data in agent-native apps. All data lives in SQL. Use when adding data models, deciding where to store data, or reading/writing application data.
  • 100storing-data
    How to store application data in agent-native apps. All data lives in SQL. Use when adding data models, deciding where to store data, or reading/writing application data.
  • 90mariadb-date-time-functions
    MariaDB date and time functions — current time (NOW, CURRENT_TIMESTAMP, SYSDATE, CURDATE, CURTIME, UTC_TIMESTAMP/UTC_DATE/UTC_TIME), arithmetic (DATE_ADD, DATE_SUB, ADDDATE, SUBDATE, INTERVAL units), differences (TIMESTAMPDIFF, TIMESTAMPADD, DATEDIFF, TIMEDIFF), extraction…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.