In DuckDB, the epoch_ms()
function serves a dual purpose. It converts timestamp values into Unix epoch time in milliseconds and also performs the reverse operation, transforming Unix epoch time values back into timestamps.
Unix epoch time is typically expressed as the number of seconds that have elapsed since January 1, 1970 (UTC), but this function returns the equivalent amount in milliseconds.
The function is similar to the epoch()
function, which returns its result in seconds. However, the epoch()
function only works in one direction; it converts a timestamp value to epoch time, but it doesn’t work the other way around like epoch_ms()
can.