TIME
TIME stores a clock time: hours, minutes, seconds and an optional fractional part. Two engines treat it as a pure time-of-day, MySQL lets it go negative, and two do not have it.
- Family
- Dates & times
- Missing in
- None of the five
- Gotchas
- 4 listed
Engine by engine
A time-of-day with optional fractional seconds. SQL Server and PostgreSQL cap it at 24 hours; MySQL's TIME is a signed duration up to 838 hours; Oracle and SQLite have no TIME-only type.
| Engine | Typ | Speicher | Notizen |
|---|---|---|---|
| SQL Server |
TIME
|
3 to 5 bytes | TIME(p) with p 0-7; the default TIME(7) has 100-nanosecond precision and needs 5 bytes. |
| PostgreSQL |
TIME
|
8 bytes | Microsecond precision; TIME(p) stays 8 bytes up to p = 6. TIME WITH TIME ZONE is 12 bytes and best avoided. |
| MySQL |
TIME
|
3 bytes plus fractional | Range -838:59:59 to 838:59:59, so MySQL's TIME doubles as a duration, not just a clock time. |
| SQLite |
TEXT
|
variable | No native TIME. Store 'HH:MM:SS' text or seconds as INTEGER and use the time() function. |
| Oracle |
DATE
|
7 bytes | No TIME-only type. The time of day lives inside DATE or TIMESTAMP; a 12:30 value needs a dummy date. |
Gotchas
Where the engines disagree. These tend to surface as bugs during a migration or a port.
- MySQL's TIME accepts negative values and hours above 23 (up to 838), because it is really an interval type. Code that assumes a clock time breaks the moment a computed duration lands in the column.
- Oracle has no TIME type. To store 12:30:00 you pick a dummy date, and comparisons then include that date whether you meant it or not.
- Fractional precision differs everywhere: SQL Server TIME(7) is 100 nanoseconds, PostgreSQL and MySQL cap at 6 digits (microseconds), and SQLite gives you whatever your text says.
- PostgreSQL's TIME WITH TIME ZONE (timetz) is 12 bytes and stores a fixed offset that cannot follow DST; the docs say it exists only for SQL standard compliance. Use timestamptz instead.
Common questions
How many bytes does TIME use?
SQL Server TIME(p) uses 3 to 5 bytes depending on precision, PostgreSQL TIME is 8 bytes, and MySQL TIME is 3 bytes plus 0 to 3 fractional bytes.
Can TIME store durations like 26 hours?
In MySQL yes: TIME reaches -838:59:59 to 838:59:59 and is the usual duration type. In SQL Server and PostgreSQL a 26-hour value overflows; use an INTERVAL or an integer of seconds.
Does TIME store a time zone?
No, except PostgreSQL's timetz, which stores a fixed offset that does not follow DST and is not recommended. Track zones with TIMESTAMPTZ instead.
Related on SQLly
- SQL data type comparison and converter Free tool
- Convert a timestamp to another timezone in SQL Server, PostgreSQL, MySQL, SQLite and Oracle Dialect comparison
- Convert a Unix timestamp to a date in SQL Server, PostgreSQL, MySQL, SQLite and Oracle Dialect comparison
- SQL SQLite date() function Funktion
- SQL TIME() function Funktion
Map a type to the other four engines
The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.