Chapter 12

Temporal Data Types in SQL

Abstract

SQL is the first programming language to have temporal data types in it. The problem is that our calendar system is irregular.

Keywords

Y2K problem

Common Era Calendar

ISO-8601

Universal Coordinated Time

YEAR

MONTH

DAY

HOUR

MINUTE

SECOND

Timestamp

Calendar date

Ordinal date

Week date

USNO

NIST

ITS

ACTS

Time zones

CURRENT_TIMESTAMP

LOCALTIMESTAMP

INTERVAL data types

Date arithmetic

OVERLAPS() predicate

History tables

State-transition constraints

Calendar tables

Report period tables

Clifford Simak wrote a science fiction novel entitled Time is the Simplest Thing in 1977. He was wrong. And the problems did not start with the Y2K problems we had in 2000, either. The calendar is irregular and the ...

Get Joe Celko's SQL for Smarties, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.