Determining the date/time of a write 

Using the WRITETIME function in a SELECT statement to determine when the date/time that the column was written to the database.

A table contains a timestamp representing the date/time that a write occurred to a column. Using the WRITETIME function in a SELECT statement returns the date/time that the column was written to the database. The output of the function is microseconds except in the case of Apache Cassandra™ 2.1 counter columns. Counter column writetime is milliseconds. This procedure continues the example from the previous procedure and calls the WRITETIME function to retrieve the date/time of the writes to the columns.

Procedure

  1. Insert more data into the table.
    INSERT INTO excelsior.clicks (
      userid, url, date, name)
      VALUES (
        cfd66ccc-d857-4e90-b1e5-df98a3d40cd6,
        'http://google.com',
        '2013-10-11', 'Bob'
    );
  2. Retrieve the date/time that the value Mary was written to the name column of the apache.org data. Use the WRITETIME function in a SELECT statement, followed by the name of a column in parentheses:
    SELECT WRITETIME (name) FROM excelsior.clicks
      WHERE url = 'http://apache.org' ALLOW FILTERING;
    The writetime output in microseconds converts to Sun, 14 Jul 2013 21:57:58 GMT or to 2:57 pm Pacific time.
    writetime(name)
    ------------------
    1373839078327001
  3. Retrieve the date/time of the last write to the date column for google.com data.
    SELECT WRITETIME (date) FROM excelsior.clicks
      WHERE url = 'http://google.com' ALLOW FILTERING;
    The writetime output in microseconds converts to Sun, 14 Jul 2013 22:03:15 GMT or 3:03 pm Pacific time.
    writetime(date)
    ------------------
    1373839395324001