Search code examples
cassandradayofweek

Cassandra - How to get the Day of week from the timestamp column?


I have a timestamp column in a Cassandra table, how do i get the day of week from the timestamp column using cql?


Solution

  • There isn't support out of the box for this but

    If using the CQL is a must you can have a look at the User Defined Functions:

    http://cassandra.apache.org/doc/latest/cql/functions.html

    http://www.datastax.com/dev/blog/user-defined-functions-in-cassandra-3-0

    http://docs.datastax.com/en//cql/latest/cql/cql_using/useCreateUDF.html

    Then you could use something as simple as:

    How to determine day of week by passing specific date?

    or even something like

    Aggregation with Group By date in Spark SQL

    And then you have a UDF that gives you day of the week when you are working with a dates.