Return the Current Timestamp in YCQL

I want to display the current timestamp in YCQL.

For that I can use the Cassandra function called now() which will, on the coordinator node, generate a new unique timeuuid in milliseconds

The timestamp portion of the timeuuid conforms to the UTC (Universal Time) standard.

				
					ycqlsh> SELECT now() FROM system.local;

 now()
--------------------------------------
 da50afb8-3a1b-11ed-b2fc-016abf4ee7d7

(1 rows)
				
			

To extract the timestamp of a timeuuid I can call the toTimestamp()  function.

				
					ycqlsh> SELECT toTimestamp(now()) FROM system.local;

 totimestamp(now())
---------------------------------
 2022-09-22 02:12:47.763000+0000

(1 rows)
				
			

Note that in the SELECT statements used in the examples above are making use of the system.local table as described in a previous YugabyteDB Tip – SIMULATE THE DUAL TABLE IN YCQL

Have Fun!