Date column

Write values using the current day/time or a string format into a date column.

Commands in this section use the Setting up the Cycling keyspace and cyclist_alt_stats table and data.

String format


date string format:


Where the elements of a date are separated with a hyphen:

  • yyyy: four-digit year

  • mm: two-digit month

  • dd: two-digit day

For example, May 5, 2017:


Getting the current day

Use toDate(now()) to insert the current day into a date field.

  • To INSERT dates:

    • Current date (today) for last_race values.

INSERT INTO cycling.cyclist_alt_stats (
  • String format (yyyy-mm-dd) for first_race value.

INSERT INTO cycling.cyclist_alt_stats (
  • To UPDATE a date field:

    • Current date (today) for last_race.

UPDATE cycling.cyclist_alt_stats
SET last_race = toDate(now())
WHERE id = ed584e99-80f7-4b13-9a90-9dc5571e6821;
  • Use formatted string (yyyy-mm-dd) for birthday.

UPDATE cycling.cyclist_alt_stats
SET birthday = '1987-03-07'
WHERE id = ed584e99-80f7-4b13-9a90-9dc5571e6821;

Select the date columns from the table.

SELECT first_race, last_race, birthday
FROM cycling.cyclist_alt_stats
WHERE id = ed584e99-80f7-4b13-9a90-9dc5571e6821;
 first_race | last_race  | birthday
 2006-03-15 | 2019-11-05 |     null

(1 rows)

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000,