v.24.12New Feature
Add toUnixTimestamp64Second Function for DateTime64 Conversion to Int64
Add functiontoUnixTimestamp64Secondwhich converts aDateTime64to aInt64value with fixed second precision, so we can support return negative value if date is before the unix epoch. #70597 (zhanglistar). #73146 (Robert Schulze).
Why it matters
This feature enables precise conversion of high-precisionDateTime64 values to standard UNIX timestamp representation in seconds, including dates prior to January 1, 1970. This expands compatibility and correctness when working with historical or negative-time data.How to use it
Use the function by passing aDateTime64 value as its argument, for example:SELECT toUnixTimestamp64Second(your_datetime64_column) FROM your_table;This will return the equivalent
Int64 UNIX timestamp value in seconds, preserving negative values for pre-epoch dates.