Calculating Time Differences in DuckDB

DuckDB has emerged as a powerful analytical database system designed for fast in-memory data processing. One common analytical task involves calculating time differences between events—whether measuring intervals between transactions, tracking service response times, or analyzing temporal patterns in time series data.

This article provides an exploration of calculating time differences in DuckDB, covering both basic and slightly more advanced techniques.

Read more

TYPEOF() vs PG_TYPEOF() in DuckDB: What’s the Difference?

You may be aware that DuckDB includes a typeof() function that works just like the SQLite equivalent; it returns the data type of its argument. But did you know that DuckDB also provides us with a pg_typeof() function that does essentially the same thing?

So why would DuckDB need a pg_typeof() function that does basically the same thing as typeof()? Let’s find out!

Read more

Subtract Days from a Date in DuckDB

DuckDB provides us with a couple of easy ways to perform additions and subtractions on dates. In particular, we can use the - operator to do the job, or the date_add() operator combined with the - operator.

Here are two options for subtracting days from a date in DuckDB.

Read more

Using LIST_RESIZE() to Resize a List in DuckDB

DuckDB provides us with a list_resize() function for those occasions where we need to resize a list. It also offers an alias called array_resize() that does exactly the same thing. When we resize a list using these functions, we specify how big we want the resulting list to be, and we can also specify a value to use for any extra elements that are added to the list.

Read more