liveBook · Manning

toTimestamp()

As explained in ScyllaDB in Action

toTimestamp() is a ScyllaDB conversion function that converts a date or time-based UUID value to a timestamp.

toTimestamp() converts a DATE or TIMEUUID value into a TIMESTAMP. The result is formatted as a readable timestamp, making date and time information easier to inspect. section 4.3.1

Extracting time from a TIMEUUID

Given a row containing a TIMEUUID, query it with SELECT text, toTimestamp(timeuuid) FROM basic WHERE text = 'uuids'; ScyllaDB returns a timestamp such as 2023-08-18 01:24:42.053000+0000 and labels the computed column system.totimestamp(timeuuid). section 4.4.1

Use the conversion functions according to the source and desired result:

  • Use toDate() to convert a TIMESTAMP or TIMEUUID to a DATE. section 4.3.1
  • Use toTimestamp() to convert a DATE or TIMEUUID to a TIMESTAMP. section 4.3.1
  • Use toUnixTimestamp() to convert a DATE, TIMESTAMP, or UUID to epoch time as a BIGINT. section 4.3.1
cqlsh:types> SELECT text, toTimestamp(timeuuid)
  FROM basic where text = 'uuids';

Inspect the exact CQL expression used to extract a timestamp from a TIMEUUID. section 4.4.1

How ScyllaDB in Action covers it

How deep it goes
Defines supported input types and demonstrates formatted output, without explaining conversion internals.
Examples
Demonstrates SELECT text, toTimestamp(timeuuid) against a row generated with now().
What it assumes
Assumes familiarity with ScyllaDB date/time types and TIMEUUID values while introducing their conversion relationships.
What you can do after
Evaluate TIMEUUID values as human-readable timestamps in CQL query results.
How it connects
Connects DATE, TIMESTAMP, TIMEUUID, UUID, toDate(), and toUnixTimestamp().

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.