Data Types: Datetime

Datetime support varies wildly among platforms; commonality is virtually nonexistent.

DB2

DB2 supports the following datetime types:

DATE
TIME
TIMESTAMP
TIMESTAMP(0to12default6)

DATE stores year, month, and day. TIME stores hour, minute, and second. TIMESTAMP stores both date and time, to a fractional position of up to 12 digits. The range of valid values is from 1 A.D. through 9999 A.D.

MySQL

MySQL supports the following datetime types:

DATE
TIME
DATETIME
TIMESTAMP

DATE stores dates from 1-Jan-1000 through 31-Dec-9999. TIME stores hour/minute/second values from −838:59:59 through 838:59:59. DATETIME stores both date and time of day (with the same range as DATE and TIME except that hours max out at 23). TIMESTAMP stores Unix timestamp values.

The first TIMESTAMP column in a row is set to the current time in any INSERT or UPDATE, unless you specify explicitly a value of your own.

Oracle

Oracle supports the following datetime types:

DATE
TIMESTAMP
TIMESTAMP WITH TIME ZONE
TIMESTAMP WITH LOCAL TIME ZONE
TIMESTAMP(0to9default6) ...

DATE stores date and time to the second. TIMESTAMP adds fractional seconds. WITH TIME ZONE adds the time zone. WITH LOCAL TIME ZONE assumes each value to be in the same time zone as the database server, with time zone translation taking place automatically between server and session time zones. The range of valid datetime values is from 4712 B.C. through 9999 A.D. You can specify a fractional precision of up to nine digits for any TIMESTAMP type. ...

Get SQL Pocket Guide, 3rd 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.