Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Convert Datetime to Unix Timestamp in CQL

How to convert Datetime to Unix timestamp in CQL

🎈 🎈 🎈
+1

    SELECT toUnixTimestamp('2018-01-02 13:50:56') / 1000 AS UnixTimestamp
    FROM your_table;            
        

Output:
----------------- | UnixTimestamp | ----------------- | 1514901056 |
Example only. There may be multiple ways to perform this operation.

Code Explanation

In this CQL query, the toUnixTimestamp() function converts the date value or column from your table into a Unix timestamp, which is represented in milliseconds.
Since Unix timestamps are typically expressed in seconds, the result is divided by 1000 to convert the milliseconds into seconds. The converted value is then aliased as UnixTimestamp in the query output.


Other useful CQL date functions

Function Description Example
toTimestamp() Converts a timeuuid or date to a timestamp type, representing the date and time. toTimestamp(now()) returns 2024-08-28 12:34:56.789
now() Returns the current time as a timeuuid. now() returns ce17f8e0-cc35-11eb-b8bc-0242ac130003
unixTimestampOf() Converts a timeuuid to a Unix timestamp in milliseconds. unixTimestampOf(now()) returns 1693227296789
dateOf() Extracts the date from a timeuuid. dateOf(now()) returns 2024-08-28
minTimeuuid() Returns the smallest timeuuid generated on the specified date. minTimeuuid('2024-08-28') returns ce17f8e0-cc35-11eb-b8bc-0242ac130003
maxTimeuuid() Returns the largest timeuuid generated on the specified date. maxTimeuuid('2024-08-28') returns ce17f8e0-cc35-11eb-b8bc-0242ac130003
Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder