0

I am new to cassandra. I want to know how can i insert system date and time through CLI (command line interface) for perticular row.

DateType and TiemUUIDType are just data types for this purpose so how can i use this two data types and insert the date and time for perticular UUID through Internal/ CLI type.

Thanks in advance.

Helping Hand..
  • 2,430
  • 4
  • 32
  • 52
  • Are you talking about the current time? If so, take a look at this question: http://stackoverflow.com/questions/19623432/how-to-get-current-timestamp-with-cql-while-using-command-line/19630738#19630738. (This question relates to CQL.) – lorcan Oct 29 '13 at 12:11
  • but i want to do the same using CLI. – Helping Hand.. Oct 29 '13 at 12:40

1 Answers1

1

To enter a timeuuid corresponding to now, use the timeuuid() function, e.g. (taken from this example):

CREATE COLUMN FAMILY blog_entry
  WITH comparator = TimeUUIDType
  AND key_validation_class=UTF8Type
  AND default_validation_class = UTF8Type;

SET blog_entry['yomama'][timeuuid()] = 'I love my new shoes!';

To enter a timestamp into a datetime function use the unix timestamp, see the following example (taken from a related question), where we insert a unix timestamp into a DateType column:

set test['userID']['dob']=567999912112;
Community
  • 1
  • 1
lorcan
  • 3,280
  • 3
  • 24
  • 31
  • i go through the corresponding question and in that way i executed the steps so at the end when i am fetching data using get test['userID']; i am getting output something like (column=dob, value=1988-01-01 07:15:12+0530, timestamp=138305546298400 so here what is 567999912112 and how to decide for entering system datetime? – Helping Hand.. Oct 29 '13 at 14:04
  • 1
    567999912112 is the unix timestamp corresponding to that date ('1988-1-1'T'01:45:12:112' GMT). To insert a date corresponding to current time you need to set the value to be the current [unix timestamp](http://stackoverflow.com/questions/1204669/how-can-i-generate-unix-timestamps). – lorcan Oct 29 '13 at 14:14
  • ok so dateof(now()) in CQL their is no such thing for CLI right? – Helping Hand.. Oct 29 '13 at 14:24
  • Great, are you happy to mark the answer correct or does it need anything extra? – lorcan Oct 30 '13 at 16:51