liveBook · Manning

Time

As explained in ScyllaDB in Action

A time is a database data type representing a time of day with fractional-second precision.

TIME represents a time of day without a date. ScyllaDB stores it as a 64-bit signed integer counting nanoseconds since midnight, while accepting readable ISO-8601-style values such as 21:07:12.123. section 4.3

Insert TIME values as strings or their underlying integer representation. When queried, cqlsh formats them with nanosecond precision and validates values when using the native type. section 4.3.1

Insert and query a time

INSERT INTO BASIC(text, timestamp, date, time) VALUES ('time', '2023-06-25 10:31:00+0000', '2023-06-25', '10:31:00'); A query returns the TIME value as 10:31:00.000000000. section 4.3.1

Table 4.6 Table times
Type
Stored as
Acceptable forms
TIMESTAMP
BIGINT representing the number of milliseconds since the Unix epoch (1970-01-01 00:00:00+0000)
1687654894759, '2023-06-24 21:02:00+0000' and other ISO-8601 compliant timestamps
DATE
32-bit unsigned integer representing the number of days since the Unix epoch (1970-01-01), with the epoch in the center of the range (2^31)
'2023-06-24', 641
TIME
64-bit signed integer representing the number of nanoseconds since midnight
'21:07:12.123' with either second, millisecond, microsecond, or nanosecond precision, 76032123000
DURATION
Three integers representing the number of months, the number of days, and the number of nanoseconds
1y4mo3w5d3h6m19s400ms20us141ns or any combination of the units

Compare TIME with TIMESTAMP, DATE, and DURATION by storage format and acceptable input forms. section 4.3

How ScyllaDB in Action covers it

How deep it goes
Explains representation, accepted inputs, precision, rendering, validation, and conversions without developing database internals.
Examples
Uses ISO-style time strings, nanosecond integer values, and cqlsh INSERT and SELECT results.
What it assumes
Assumes familiarity with database columns and CQL INSERT and SELECT statements.
What you can do after
Operate TIME through CQL and cqlsh using readable values or nanosecond integers.
How it connects
Distinguishes TIME from TIMESTAMP, DATE, and DURATION by whether the value includes a date or represents elapsed time.

Also explained in

Compare how 2 books explain time →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.