Current Unix Timestamp SECONDS SINCE JAN 01 1970

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

How to convert Unix timestamp to Datetime in CQL

🎈 🎈 🎈
+1

    SELECT toTimestamp(UnixTimestamp * 1000) AS ConvertedDate
    FROM your_table;                    
        

Output:
-------------------------- | ConvertedDate | -------------------------- | 1975-01-01 12:22:11 |
Example only. There may be multiple ways to perform this operation.

Code Explanation

In this CQL (Cassandra Query Language) query, the toTimestamp() function is used to perform the conversion from Unix timestamp to date.
Since Unix timestamps are typically recorded in seconds, and Cassandra's timestamp type expects the value in milliseconds, the 'UnixTimestamp' (eg 157810931) is multiplied by 1000 to convert seconds into milliseconds
The result is then converted to a timestamp, which represents a date and time in the format YYYY-MM-DD HH:MM:SS, and is aliased as 'ConvertedDate' in the query output.


Other useful CQL date functions

Function Description Example
toUnixTimestamp() Converts a timeuuid or date to a Unix timestamp in milliseconds. toUnixTimestamp(date_column) returns 1693227296789
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