v.20.5New Feature

Added DateTime64 Import/Export Functions with Precision Options

Added new functions to import/export DateTime64 as Int64 with various precision: to-/fromUnixTimestamp64Milli/-Micro/-Nano. #10923 (Vasily Nemkov).
Added new functions to convert DateTime64 values to and from Int64 representing Unix timestamps with millisecond, microsecond, and nanosecond precision.

Why it matters

These functions solve the problem of efficiently importing and exporting DateTime64 data as integer Unix timestamps at various precisions, facilitating data interoperability and precise time handling in user workloads.

How to use it

Use the new functions toUnixTimestamp64Milli, toUnixTimestamp64Micro, and toUnixTimestamp64Nano to convert DateTime64 values to Int64 Unix timestamps with millisecond, microsecond, and nanosecond precision respectively. Corresponding inverse functions fromUnixTimestamp64Milli, fromUnixTimestamp64Micro, and fromUnixTimestamp64Nano convert these integer timestamps back to DateTime64. Example usage:

sql<br>SELECT toUnixTimestamp64Nano(event_time) FROM table;<br>SELECT fromUnixTimestamp64Micro(unixtime_int) FROM table;<br>