How do I get current timestamp with CQL while using Command Line?

1,738 views
Skip to first unread message

compte...@gmail.com

unread,
Oct 27, 2013, 5:04:11 PM10/27/13
to java-dri...@lists.datastax.com
I am trying to insert into my CQL table from the command line. I am able to insert everything. But I am wondering if I have a timestamp column, then how can I insert into timestamp column from the command line? Basically, I want to insert current timestamp whenever I am inserting into my CQL table -

Currently, I am hardcoding the timestamp whenever I am inserting into my below CQL table -

    CREATE TABLE TEST (ID TEXT, NAME TEXT, VALUE TEXT, LAST_MODIFIED_DATE TIMESTAMP, PRIMARY KEY (ID));
   
    INSERT INTO TEST (ID, NAME, VALUE, LAST_MODIFIED_DATE) VALUES ('1', 'elephant',  'SOME_VALUE', 1382655211694);
   
Is there any way to get the current timestamp using some predefined functions in CQL so that while inserting into above table, I can use that method to get the current timestamp and then insert into above table?

Jan Algermissen

unread,
Oct 27, 2013, 5:16:07 PM10/27/13
to java-dri...@lists.datastax.com
Try dateOf(now())  I think that worked for me a while ago.

Jan

compte...@gmail.com

unread,
Oct 28, 2013, 1:03:39 AM10/28/13
to java-dri...@lists.datastax.com
Thanks Jan.. It works fine now..!!
Reply all
Reply to author
Forward
0 new messages