DuckDB has a today()
function that returns the current date. It’s similar to the current_date
function, which does the same thing.
Here, we’ll look at how the today()
function works, along with some basic examples.
DuckDB has a today()
function that returns the current date. It’s similar to the current_date
function, which does the same thing.
Here, we’ll look at how the today()
function works, along with some basic examples.
The make_timestamp()
function in DuckDB is a handy tool for creating timestamp values from individual components. It allows us to construct timestamp values using two alternative approaches; by specifying the number of milliseconds from epoch, or by specifying the year, month, day, hour, minute, and second components separately.
Let’s take a look at the make_timestamp()
function, along with some examples.
DuckDB provides an epoch_ns()
function that returns the Unix epoch time from a given date/time value in nanoseconds.
Unix epoch time is typically expressed as the number of seconds that have elapsed since January 1, 1970 (UTC), but it can also be expressed in other units, such as milliseconds, microseconds, and nanoseconds. DuckDB has specific functions for each of these units, with epoch_ns()
being the function that returns it in nanoseconds.
When working with dates in DuckDB, some common tasks we might need to perform include extracting date parts from a date or timestamp value. For example we might want to extract the year from a date. Fortunately, DuckDB provides us with an abundance of options for doing that.
In this article, we’ll look at five different functions extract the year from a date in DuckDB.
Continue readingDuckDB provides us with a bunch of epoch...()
functions that enable us to get the Unix epoch time from a given date/time value. Different functions return their result using different units (for example seconds, milliseconds, etc). The epoch_us()
function returns its result in microseconds.
Unix epoch time is typically expressed as the number of seconds that have elapsed since January 1, 1970 (UTC), but epoch_us()
function returns the equivalent amount in microseconds.
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.
DuckDB’s epoch()
function is a useful time conversion tool that allows us to transform timestamp values into Unix epoch time – the number of seconds that have elapsed since January 1, 1970 (UTC).
The function is particularly useful when working with time-series data and when we need to perform mathematical operations on timestamp values. By converting timestamps to integer representations, we can easily calculate time differences, group time-based data, or integrate with systems that use epoch time.
Continue readingDuckDB provides us with a good selection of functions for working with date/time values. Among them is date_part()
, which we can use to extract specific components from dates, timestamps, and intervals.
In this article, we’ll look how the date_part()
function works, along with some basic examples.
DuckDB offers a variety of date functions, one of which is the extract()
function. This function is designed to retrieve a specific date part from a date or timestamp value, and it can also be applied to intervals.
In this article, we’ll take a closer look at the extract()
function and provide some straightforward examples to illustrate how it works.
The range()
function is a handy utility in DuckDB that enables us to generate sequences of numbers or timestamps. We specify the starting point, the end point, and the step to use for each value in the range.
In this article, we’ll take a look at DuckDB’s range()
function, along with some basic examples.